35 #ifndef _BLAZE_UTIL_NUMERICCAST_H_ 36 #define _BLAZE_UTIL_NUMERICCAST_H_ 69 template<
typename To,
typename From >
70 constexpr
bool IsCriticalIntIntConversion_v =
71 ( IsIntegral_v<To> && IsIntegral_v<From> && !IsSame_v<To,From> );
81 template<
typename To,
typename From >
82 constexpr
bool IsCriticalFloatIntConversion_v =
83 ( IsIntegral_v<To> && IsFloatingPoint_v<From> );
93 template<
typename To,
typename From >
94 constexpr
bool IsCriticalFloatFloatConversion_v =
95 ( IsFloatingPoint_v<To> && IsFloatingPoint_v<From> && (
sizeof(To) <
sizeof(From) ) );
105 template<
typename To,
typename From >
106 constexpr
bool IsUncriticalConversion_v =
107 ( !IsCriticalIntIntConversion_v<To,From> &&
108 !IsCriticalFloatIntConversion_v<To,From> &&
109 !IsCriticalFloatFloatConversion_v<To,From> );
125 template<
typename To,
typename From >
inline To
numeric_cast( From from );
138 template<
typename To,
typename From >
139 inline EnableIf_t< IsUncriticalConversion_v<To,From>, To >
140 numeric_cast_backend( From from ) noexcept
158 template<
typename To,
typename From >
159 inline EnableIf_t< IsCriticalIntIntConversion_v<To,From>, To >
160 numeric_cast_backend( From from )
162 if( (
sizeof(To) <
sizeof(From) || ( IsSigned_v<To> && IsUnsigned_v<From> ) ) &&
166 if( IsSigned_v<From> &&
188 template<
typename To,
typename From >
189 inline EnableIf_t< IsCriticalFloatIntConversion_v<To,From>, To >
190 numeric_cast_backend( From from )
218 template<
typename To,
typename From >
219 inline EnableIf_t< IsCriticalFloatFloatConversion_v<To,From>, To >
220 numeric_cast_backend( From from )
267 template<
typename To
274 return numeric_cast_backend<To>( from );
Constraint on the data type.
Header file for the IsSame and IsStrictlySame type traits.
Header file for exception macros.
Header file for the IsIntegral type trait.
To numeric_cast(From from)
Checked conversion of values of numeric type.
Definition: NumericCast.h:269
#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:58
Header file for the IsFloatingPoint type trait.
#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) min(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise minimum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1162
decltype(auto) trunc(const DenseMatrix< MT, SO > &dm)
Applies the trunc() function to each single element of the dense matrix dm.
Definition: DMatMapExpr.h:1268
decltype(auto) max(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise maximum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1198
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.
Header file for the IntegralConstant class template.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression,...
Definition: Assert.h:101