add_reference.hpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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_ADD_REFERENCE_HPP_INCLUDED
  8. #define BOOST_TT_ADD_REFERENCE_HPP_INCLUDED
  9. #include <boost/detail/workaround.hpp>
  10. #include <boost/config.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 <typename T>
  18. struct add_reference_impl
  19. {
  20. typedef T& type;
  21. };
  22. #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
  23. template <typename T>
  24. struct add_reference_impl<T&&>
  25. {
  26. typedef T&& type;
  27. };
  28. #endif
  29. } // namespace detail
  30. template <class T> struct add_reference
  31. {
  32. typedef typename boost::detail::add_reference_impl<T>::type type;
  33. };
  34. template <class T> struct add_reference<T&>
  35. {
  36. typedef T& type;
  37. };
  38. // these full specialisations are always required:
  39. template <> struct add_reference<void> { typedef void type; };
  40. #ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
  41. template <> struct add_reference<const void> { typedef const void type; };
  42. template <> struct add_reference<const volatile void> { typedef const volatile void type; };
  43. template <> struct add_reference<volatile void> { typedef volatile void type; };
  44. #endif
  45. #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
  46. template <class T> using add_reference_t = typename add_reference<T>::type;
  47. #endif
  48. } // namespace boost
  49. #endif // BOOST_TT_ADD_REFERENCE_HPP_INCLUDED