safe_common.hpp 913 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #ifndef BOOST_NUMERIC_SAFE_COMMON_HPP
  2. #define BOOST_NUMERIC_SAFE_COMMON_HPP
  3. // Copyright (c) 2012 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 <type_traits>
  9. namespace boost {
  10. namespace safe_numerics {
  11. // default implementations for required meta-functions
  12. template<typename T>
  13. struct is_safe : public std::false_type
  14. {};
  15. template<typename T>
  16. struct base_type {
  17. using type = T;
  18. };
  19. template<class T>
  20. constexpr const typename base_type<T>::type & base_value(const T & t) {
  21. return static_cast<const typename base_type<T>::type & >(t);
  22. }
  23. template<typename T>
  24. struct get_promotion_policy {
  25. using type = void;
  26. };
  27. template<typename T>
  28. struct get_exception_policy {
  29. using type = void;
  30. };
  31. } // safe_numerics
  32. } // boost
  33. #endif // BOOST_NUMERIC_SAFE_COMMON_HPP