implicit_cast.hpp 810 B

123456789101112131415161718192021222324252627282930313233
  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. namespace boost {
  8. namespace detail {
  9. template<class T> struct icast_identity
  10. {
  11. typedef T type;
  12. };
  13. } // namespace detail
  14. // implementation originally suggested by C. Green in
  15. // http://lists.boost.org/MailArchives/boost/msg00886.php
  16. // The use of identity creates a non-deduced form, so that the
  17. // explicit template argument must be supplied
  18. template <typename T>
  19. inline T implicit_cast (typename boost::detail::icast_identity<T>::type x) {
  20. return x;
  21. }
  22. } // namespace boost
  23. #endif // BOOST_IMPLICIT_CAST_DWA200356_HPP