implicit_cast.hpp 892 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright David Abrahams 2003.
  2. // Distributed under the Boost Software License, Version 1.0. (See
  3. // accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef BOOST_IMPLICIT_CAST_DWA200356_HPP
  6. #define BOOST_IMPLICIT_CAST_DWA200356_HPP
  7. #include <boost/config.hpp>
  8. #ifdef BOOST_HAS_PRAGMA_ONCE
  9. # pragma once
  10. #endif
  11. namespace boost {
  12. namespace detail {
  13. template<class T> struct icast_identity
  14. {
  15. typedef T type;
  16. };
  17. } // namespace detail
  18. // implementation originally suggested by C. Green in
  19. // http://lists.boost.org/MailArchives/boost/msg00886.php
  20. // The use of identity creates a non-deduced form, so that the
  21. // explicit template argument must be supplied
  22. template <typename T>
  23. constexpr T implicit_cast (typename boost::detail::icast_identity<T>::type x) {
  24. return x;
  25. }
  26. } // namespace boost
  27. #endif // BOOST_IMPLICIT_CAST_DWA200356_HPP