safe_numeric.hpp 914 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 "boost/safe_numerics/concept/safe_numeric.hpp"
  12. namespace boost {
  13. namespace safe_numerics {
  14. template<class T>
  15. struct SafeNumeric : public Numeric<T> {
  16. BOOST_CONCEPT_USAGE(SafeNumeric<T>){
  17. using t1 = get_exception_policy<T>;
  18. using t2 = get_promotion_policy<T>;
  19. using t3 = base_type<T>;
  20. }
  21. constexpr static bool value = is_safe<T>::value && Numeric<T>::value ;
  22. constexpr operator bool (){
  23. return value;
  24. }
  25. };
  26. } // safe_numerics
  27. } // boost
  28. #endif // BOOST_NUMERIC_CONCEPT_SAFE_NUMERIC_HPP