5 #define SAFEINT_DISABLE_ADDRESS_OPERATOR 6 #include <hilti/rt/3rdparty/SafeInt/SafeInt.hpp> 7 #include <hilti/rt/exception.h> 14 static void SafeIntOnOverflow() __attribute__((noreturn)) {
throw Overflow(
"integer overflow"); }
16 static void SafeIntOnDivZero() __attribute__((noreturn)) {
throw DivisionByZero(
"integer division by zero"); }
21 using safe = SafeInt<T, detail::SafeIntException>;
26 template<
typename O,
typename T>
27 inline auto operator<<(O& out, const hilti::rt::integer::safe<T>& x)
28 -> std::enable_if_t<std::is_base_of_v<std::ostream, O>, O>& {
29 if ( std::is_same<T, int8_t>() )
30 out << static_cast<int16_t>(x);
31 else if ( std::is_same<T, uint8_t>() )
32 out << static_cast<uint16_t>(x);
Definition: safe-int.h:12