chsvlib
chsv helper source code

◆ cast_overflows()

constexpr bool Chusov::cast_overflows ( From  val)
constexprnoexcept

Checks whether conversion of the parameter to the given type would overflow.

Template Parameters
ToThe type to which the conversion takes place.
FromA deducable type of the parameter to convert.
Parameters
valA value to convert.
Returns
true if the conversion would overflow, and false otherwise.

The function checks if both To and From are integral types, both signed and/or unsigned. If either of the two types are not integral, the function returns true if, and only if, To and From denote the same type.