31 template<
typename T >
37 static constexpr T
lowest = std::numeric_limits< T >::lowest();
41 static constexpr T
epsilon = std::numeric_limits< T >::epsilon();
43 static constexpr T
round_error = std::numeric_limits< T >::round_error();
45 static constexpr T
infinity = std::numeric_limits< T >::infinity();
47 static constexpr T
quiet_NaN = std::numeric_limits< T >::quiet_NaN();
49 static constexpr T
signaling_NaN = std::numeric_limits< T >::signaling_NaN();
51 static constexpr T
denorm_min = std::numeric_limits< T >::denorm_min();
60 template<
typename T >
66 T
const lowest = std::numeric_limits< T >::lowest();
70 T
const epsilon = std::numeric_limits< T >::epsilon();
72 T
const round_error = std::numeric_limits< T >::round_error();
74 T
const infinity = std::numeric_limits< T >::infinity();
76 T
const quiet_NaN = std::numeric_limits< T >::quiet_NaN();
80 T
const denorm_min = std::numeric_limits< T >::denorm_min();
91 template<
typename T,
typename U >
92 constexpr
bool sameSignedness = ( std::is_signed< T >::value && std::is_signed< U >::value ) ||
93 ( std::is_unsigned< T >::value && std::is_unsigned< U >::value );
100 template<
typename INPUT,
typename OUTPUT >
101 constexpr
bool canEasilyConvert =
sizeof( INPUT ) <
sizeof( OUTPUT ) ||
102 (
sizeof( INPUT ) ==
sizeof( OUTPUT ) && sameSignedness< INPUT, OUTPUT > );
112 template<
typename OUTPUT,
typename INPUT >
113 std::enable_if_t< internal::canEasilyConvert< INPUT, OUTPUT >, OUTPUT >
117 static_assert( std::is_integral< INPUT >::value,
"INPUT must be an integral type." );
118 static_assert( std::is_integral< OUTPUT >::value,
"OUTPUT must be an integral type." );
120 return OUTPUT{ input };
129 template<
typename OUTPUT,
typename INPUT >
130 std::enable_if_t< !internal::canEasilyConvert< INPUT, OUTPUT > &&
131 std::is_unsigned< INPUT >::value,
136 static_assert( std::is_integral< INPUT >::value,
"INPUT must be an integral type." );
137 static_assert( std::is_integral< OUTPUT >::value,
"OUTPUT must be an integral type." );
141 return static_cast< OUTPUT
>( input );
150 template<
typename OUTPUT,
typename INPUT >
151 std::enable_if_t< !internal::canEasilyConvert< INPUT, OUTPUT > &&
152 !std::is_unsigned< INPUT >::value,
157 static_assert( std::is_integral< INPUT >::value,
"INPUT must be an integral type." );
158 static_assert( std::is_integral< OUTPUT >::value,
"OUTPUT must be an integral type." );
164 using ConditionallyUnsigned = std::conditional_t< std::is_unsigned< OUTPUT >::value, std::make_unsigned_t< INPUT >, INPUT >;
167 return static_cast< OUTPUT
>( input );
static constexpr T min
The smallest finite value T can hold.
#define LVARRAY_ERROR_IF_LT(lhs, rhs)
Raise a hard error if one value compares less than the other.
static constexpr T signaling_NaN
A signaling NaN (if T is a floating point).
static constexpr T infinity
A positive infinity value (if T is a floating point).
#define LVARRAY_ERROR_IF_GT(lhs, rhs)
Raise a hard error if one value compares greater than the other.
static constexpr T denorm_min
The smallest positive subnormal value (if T is a floating point).
static constexpr T round_error
The maximum rounding error (if T is a floating point).
The same as NumericLimits except the entries are not static or constexpr.
A wrapper for the std::numeric_limits< T > member functions, this allows their values to be used on d...
static constexpr T quiet_NaN
A quiet NaN (if T is a floating point).
Contains a bunch of macro definitions.
static constexpr T lowest
The lowest finite value T can hold.
static constexpr T epsilon
The difference between 1.0 and the next representable value (if T is floating point).
constexpr std::enable_if_t< std::is_arithmetic< T >::value, T > min(T const a, T const b)
constexpr std::enable_if_t< std::is_arithmetic< T >::value, T > max(T const a, T const b)
std::enable_if_t< internal::canEasilyConvert< INPUT, OUTPUT >, OUTPUT > constexpr integerConversion(INPUT input)
#define LVARRAY_HOST_DEVICE
Mark a function for both host and device usage.
static constexpr T max
The largest finite value T can hold.