35 #ifndef NEKTAR_LIB_UTILITIES_CHECKEDCAST_H
36 #define NEKTAR_LIB_UTILITIES_CHECKEDCAST_H
41 #include <type_traits>
45 namespace LibUtilities
51 class =
typename std::enable_if
53 std::is_floating_point<typename std::remove_reference<Ti>::type>::value
54 && std::is_integral <typename std::remove_reference<To>::type>::value
59 Ti min = std::numeric_limits<To>::min();
60 Ti max = std::numeric_limits<To>::max();
61 ASSERTL0(param >= min,
"Casting would narrow (underflow).");
62 ASSERTL0(param <= max,
"Casting would narrow (overflow).");
63 return static_cast<To
>(param);
#define ASSERTL0(condition, msg)
#define LIB_UTILITIES_EXPORT
To checked_cast(const Ti param)
checked cast from float types only to int types