35#ifndef _BLAZE_UTIL_NUMERICCAST_H_
36#define _BLAZE_UTIL_NUMERICCAST_H_
69template<
typename To,
typename From >
70constexpr bool IsCriticalIntIntConversion_v =
81template<
typename To,
typename From >
82constexpr bool IsCriticalFloatIntConversion_v =
93template<
typename To,
typename From >
94constexpr bool IsCriticalFloatFloatConversion_v =
105template<
typename To,
typename From >
106constexpr bool IsUncriticalConversion_v =
107 ( !IsCriticalIntIntConversion_v<To,From> &&
108 !IsCriticalFloatIntConversion_v<To,From> &&
109 !IsCriticalFloatFloatConversion_v<To,From> );
125template<
typename To,
typename From >
inline To
numeric_cast( From from );
138template<
typename To,
typename From >
140 numeric_cast_backend( From from )
noexcept
158template<
typename To,
typename From >
160 numeric_cast_backend( From from )
163 ( from > From( std::numeric_limits<To>::max() ) ) ) {
168 ( from < From( std::numeric_limits<To>::min() ) ) ) {
190template<
typename To,
typename From >
192 numeric_cast_backend( From from )
196 if( from > From( std::numeric_limits<To>::max() ) ) {
200 if( from < From( std::numeric_limits<To>::min() ) ) {
222template<
typename To,
typename From >
224 numeric_cast_backend( From from )
226 if( from > From( std::numeric_limits<To>::max() ) ) {
230 if( from < From( std::numeric_limits<To>::min() ) ) {
280 return numeric_cast_backend<To>( from );
Header file for run time assertion macros.
Header file for the EnableIf class template.
Header file for the IntegralConstant class template.
Header file for the IsFloatingPoint type trait.
Header file for the IsIntegral type trait.
Header file for the IsSame and IsStrictlySame type traits.
Header file for the IsSigned type trait.
Header file for the IsUnsigned type trait.
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_BE_NUMERIC_TYPE(T)
Constraint on the data type.
Definition Numeric.h:61
decltype(auto) trunc(const DenseMatrix< MT, SO > &dm)
Applies the trunc() function to each single element of the dense matrix dm.
Definition DMatMapExpr.h:1408
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition Assert.h:101
constexpr bool IsSigned_v
Auxiliary variable template for the IsSigned type trait.
Definition IsSigned.h:97
constexpr bool IsSame_v
Auxiliary variable template for the IsSame type trait.
Definition IsSame.h:159
constexpr bool IsFloatingPoint_v
Auxiliary variable template for the IsFloatingPoint type trait.
Definition IsFloatingPoint.h:95
constexpr bool IsUnsigned_v
Auxiliary variable template for the IsUnsigned type trait.
Definition IsUnsigned.h:97
constexpr bool IsIntegral_v
Auxiliary variable template for the IsIntegral type trait.
Definition IsIntegral.h:95
To numeric_cast(From from)
Checked conversion of values of numeric type.
Definition NumericCast.h:275
#define BLAZE_THROW_UNDERFLOW_ERROR(MESSAGE)
Macro for the emission of a std::underflow_error exception.
Definition Exception.h:475
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition EnableIf.h:138
#define BLAZE_THROW_OVERFLOW_ERROR(MESSAGE)
Macro for the emission of a std::overflow_error exception.
Definition Exception.h:427
Header file for exception macros.