real_cast.hpp 744 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright John Maddock 2006.
  2. // Use, modification and distribution are subject to the
  3. // Boost Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef BOOST_MATH_TOOLS_REAL_CAST_HPP
  6. #define BOOST_MATH_TOOLS_REAL_CAST_HPP
  7. #include <boost/math/tools/config.hpp>
  8. #ifdef _MSC_VER
  9. #pragma once
  10. #endif
  11. namespace boost{ namespace math
  12. {
  13. namespace tools
  14. {
  15. template <class To, class T>
  16. inline BOOST_MATH_CONSTEXPR To real_cast(T t) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(T) && BOOST_MATH_IS_FLOAT(To))
  17. {
  18. return static_cast<To>(t);
  19. }
  20. } // namespace tools
  21. } // namespace math
  22. } // namespace boost
  23. #endif // BOOST_MATH_TOOLS_REAL_CAST_HPP