mirror of
https://github.com/boostorg/safe_numerics.git
synced 2026-02-03 09:22:19 +00:00
removed constexpr from exception policies. this eliminates obstacle to gcc compilation which doesn't support constexpr throw unfortunately, all versions of gcc trip compiler fault so gcc not supported for now safe_literal - make this an unsafe type since it doesn't have policies - this might change in the future
63 lines
1.3 KiB
C++
63 lines
1.3 KiB
C++
#ifndef BOOST_NUMERIC_EXCEPTION
|
|
#define BOOST_NUMERIC_EXCEPTION
|
|
|
|
// MS compatible compilers support #pragma once
|
|
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
|
# pragma once
|
|
#endif
|
|
|
|
// Copyright (c) 2012 Robert Ramey
|
|
//
|
|
// Distributed under the Boost Software License, Version 1.0. (See
|
|
// accompanying file LICENSE_1_0.txt or copy at
|
|
// http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
// contains operations for doing checked aritmetic on NATIVE
|
|
// C++ types.
|
|
|
|
#include "concept/exception_policy.hpp"
|
|
|
|
namespace boost {
|
|
namespace numeric {
|
|
|
|
enum class exception_type {
|
|
no_exception,
|
|
overflow_error,
|
|
underflow_error,
|
|
range_error,
|
|
domain_error,
|
|
uninitialized
|
|
};
|
|
|
|
template<class EP>
|
|
void
|
|
dispatch(const exception_type & e, char const * msg){
|
|
switch(e){
|
|
case exception_type::overflow_error:
|
|
EP::overflow_error(msg);
|
|
break;
|
|
case exception_type::underflow_error:
|
|
EP::underflow_error(msg);
|
|
break;
|
|
case exception_type::range_error:
|
|
EP::range_error(msg);
|
|
break;
|
|
case exception_type::domain_error:
|
|
EP::domain_error(msg);
|
|
break;
|
|
case exception_type::uninitialized:
|
|
EP::domain_error(msg);
|
|
break;
|
|
case exception_type::no_exception:
|
|
break;
|
|
default:
|
|
assert(false);
|
|
break;
|
|
}
|
|
}
|
|
|
|
} // numeric
|
|
} // boost
|
|
|
|
#endif // BOOST_NUMERIC_CHECKED_RESULT
|