remove_reference.hpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000.
  2. // Use, modification and distribution are subject to the Boost Software License,
  3. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt).
  5. //
  6. // See http://www.boost.org/libs/type_traits for most recent version including documentation.
  7. #ifndef BOOST_TT_REMOVE_REFERENCE_HPP_INCLUDED
  8. #define BOOST_TT_REMOVE_REFERENCE_HPP_INCLUDED
  9. #include <boost/config.hpp>
  10. #include <boost/detail/workaround.hpp>
  11. namespace boost {
  12. namespace detail{
  13. //
  14. // We can't filter out rvalue_references at the same level as
  15. // references or we get ambiguities from msvc:
  16. //
  17. template <class T>
  18. struct remove_rvalue_ref
  19. {
  20. typedef T type;
  21. };
  22. #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
  23. template <class T>
  24. struct remove_rvalue_ref<T&&>
  25. {
  26. typedef T type;
  27. };
  28. #endif
  29. } // namespace detail
  30. template <class T> struct remove_reference{ typedef typename boost::detail::remove_rvalue_ref<T>::type type; };
  31. template <class T> struct remove_reference<T&>{ typedef T type; };
  32. #if defined(BOOST_ILLEGAL_CV_REFERENCES)
  33. // these are illegal specialisations; cv-qualifies applied to
  34. // references have no effect according to [8.3.2p1],
  35. // C++ Builder requires them though as it treats cv-qualified
  36. // references as distinct types...
  37. template <class T> struct remove_reference<T&const>{ typedef T type; };
  38. template <class T> struct remove_reference<T&volatile>{ typedef T type; };
  39. template <class T> struct remove_reference<T&const volatile>{ typedef T type; };
  40. #endif
  41. #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
  42. template <class T> using remove_reference_t = typename remove_reference<T>::type;
  43. #endif
  44. } // namespace boost
  45. #endif // BOOST_TT_REMOVE_REFERENCE_HPP_INCLUDED