35#ifndef NEKTAR_LIB_UTILITIES_CHECKEDCAST_H
36#define NEKTAR_LIB_UTILITIES_CHECKEDCAST_H
45template <
class To,
class Ti,
46 class =
typename std::enable_if<
47 std::is_floating_point<
48 typename std::remove_reference<Ti>::type>::value &&
50 typename std::remove_reference<To>::type>::value>::type>
53 Ti min = std::numeric_limits<To>::min();
54 Ti max = std::numeric_limits<To>::max();
55 ASSERTL0(param >= min,
"Casting would narrow (underflow).");
56 ASSERTL0(param <= max,
"Casting would narrow (overflow).");
57 return static_cast<To
>(param);
#define ASSERTL0(condition, msg)
To checked_cast(const Ti param)
checked cast from float types only to int types