35 #ifndef _BLAZE_UTIL_NUMERICCAST_H_ 36 #define _BLAZE_UTIL_NUMERICCAST_H_ 74 template<
typename To,
typename From >
75 struct IsCriticalIntIntConversion
79 enum :
size_t { value = And< IsIntegral<To>
81 , Not< IsSame<To,From> > >::value };
93 template<
typename To,
typename From >
94 struct IsCriticalFloatIntConversion
98 enum :
size_t { value = And< IsIntegral<To>
99 , IsFloatingPoint<From> >::value };
111 template<
typename To,
typename From >
112 struct IsCriticalFloatFloatConversion
116 enum :
size_t { value = And< IsFloatingPoint<To>
117 , IsFloatingPoint<From>
118 , Bool< ( sizeof(To) < sizeof(From) ) > >::value };
130 template<
typename To,
typename From >
131 struct IsUncriticalConversion
135 enum :
size_t { value = !IsCriticalIntIntConversion<To,From>::value &&
136 !IsCriticalFloatIntConversion<To,From>::value &&
137 !IsCriticalFloatFloatConversion<To,From>::value };
155 template<
typename To,
typename From >
inline To
numeric_cast( From from );
168 template<
typename To,
typename From >
169 inline EnableIf_< IsUncriticalConversion<To,From>, To >
170 numeric_cast_backend( From from ) noexcept
188 template<
typename To,
typename From >
189 inline EnableIf_< IsCriticalIntIntConversion<To,From>, To >
190 numeric_cast_backend( From from )
192 if( (
sizeof(To) <
sizeof(From) || ( IsSigned<To>::value && IsUnsigned<From>::value ) ) &&
196 if( IsSigned<From>::value &&
218 template<
typename To,
typename From >
219 inline EnableIf_< IsCriticalFloatIntConversion<To,From>, To >
220 numeric_cast_backend( From from )
248 template<
typename To,
typename From >
249 inline EnableIf_< IsCriticalFloatFloatConversion<To,From>, To >
250 numeric_cast_backend( From from )
297 template<
typename To
304 return numeric_cast_backend<To>( from );
Constraint on the data type.
Header file for the FalseType type/value trait base class.
Header file for the IsSame and IsStrictlySame type traits.
Header file for exception macros.
Header file for the IsIntegral type trait.
Header file for the And class template.
const ElementType_< MT > min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1762
To numeric_cast(From from)
Checked conversion of values of numeric type.
Definition: NumericCast.h:299
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1809
#define BLAZE_THROW_OVERFLOW_ERROR(MESSAGE)
Macro for the emission of a std::overflow_error exception.This macro encapsulates the default way of ...
Definition: Exception.h:427
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Header file for the IsFloatingPoint type trait.
Header file for the Or class template.
#define BLAZE_THROW_UNDERFLOW_ERROR(MESSAGE)
Macro for the emission of a std::underflow_error exception.This macro encapsulates the default way of...
Definition: Exception.h:475
decltype(auto) trunc(const DenseMatrix< MT, SO > &dm)
Applies the trunc() function to each single element of the dense matrix dm.
Definition: DMatMapExpr.h:1263
Header file for the Not class template.
Header file for the EnableIf class template.
Header file for run time assertion macros.
#define BLAZE_CONSTRAINT_MUST_BE_NUMERIC_TYPE(T)
Constraint on the data type.In case the given data type T is not a numeric (integral or floating poin...
Definition: Numeric.h:61
Header file for the IsSigned type trait.
Header file for the IsUnsigned type trait.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
Header file for the Bool class template.
Header file for the TrueType type/value trait base class.