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