typename UV
>
struct exception_policy {
- static constexpr void on_arithmetic_error(
+ constexpr static void on_arithmetic_error(
const safe_numerics_error & e,
const char * msg
){
- AE(e, msg);
+ AE()(e, msg);
}
- static constexpr void on_implementation_defined_behavior(
+ constexpr static void on_implementation_defined_behavior(
const safe_numerics_error & e,
const char * msg
){
- IDB(e, msg);
+ IDB()(e, msg);
}
- static constexpr void on_undefined_behavior(
+ constexpr static void on_undefined_behavior(
const safe_numerics_error & e,
const char * msg
){
- UB(e, msg);
+ UB()(e, msg);
}
- static constexpr void on_uninitialized_value(
+ constexpr static void on_uninitialized_value(
const safe_numerics_error & e,
const char * msg
){
- UV(e, msg);
+ UV()(e, msg);
}
};
// ignore any error and just return.
struct ignore_exception {
- constexpr ignore_exception(const safe_numerics_error &, const char * ){}
+ constexpr ignore_exception() = default;
+ constexpr void operator () (
+ const boost::safe_numerics::safe_numerics_error &,
+ const char *
+ ){}
};
// emit compile time error if this is invoked.
struct trap_exception {
-#if 1
- //constexpr trap_exception(const safe_numerics_error & e, const char * );
- trap_exception() = delete;
- trap_exception(const trap_exception &) = delete;
- trap_exception(trap_exception &&) = delete;
-#endif
+ constexpr trap_exception() = default;
+ // error will occur on operator call.
+ // hopefully this will display arguments
};
// If an exceptional condition is detected at runtime throw the exception.
struct throw_exception {
+ constexpr throw_exception() = default;
#ifndef BOOST_NO_EXCEPTIONS
- throw_exception(const safe_numerics_error & e, const char * message){
+ void operator()(
+ const safe_numerics_error & e,
+ const char * message
+ ){
throw std::system_error(std::error_code(e), message);
}
#else
- trap_exception(const safe_numerics_error & e, const char * message);
+ constexpr trap_exception()(const safe_numerics_error & e, const char * message);
#endif
};