safe_numeric.hpp 876 B

12345678910111213141516171819202122232425262728293031323334
  1. #ifndef BOOST_NUMERIC_CONCEPT_SAFE_NUMERIC_HPP
  2. #define BOOST_NUMERIC_CONCEPT_SAFE_NUMERIC_HPP
  3. // Copyright (c) 2015 Robert Ramey
  4. //
  5. // Distributed under the Boost Software License, Version 1.0. (See
  6. // accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. #include <limits>
  9. #include <typetraits>
  10. #include <boost/concept/usage.hpp>
  11. #include "concept/numeric.hpp"
  12. namespace boost {
  13. namespace safe_numerics {
  14. template<class T>
  15. struct SafeNumeric : public Numeric<T> {
  16. static_assert(
  17. is_safe<T>::value,
  18. "std::numeric_limits<T> has not been specialized for this type"
  19. );
  20. BOOST_CONCEPT_USAGE(SafeNumeric){
  21. using t1 = get_exception_policy<T>;
  22. using t2 = get_promotion_policy<T>;
  23. using t3 = base_type<T>;
  24. }
  25. };
  26. } // safe_numerics
  27. } // boost
  28. #endif // BOOST_NUMERIC_CONCEPT_SAFE_NUMERIC_HPP