copy_reference.hpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. Copyright 2019 Glen Joseph Fernandes
  3. (glenjofe@gmail.com)
  4. Distributed under the Boost Software License,
  5. Version 1.0. (See accompanying file LICENSE_1_0.txt
  6. or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. */
  8. #ifndef BOOST_TT_COPY_REFERENCE_HPP_INCLUDED
  9. #define BOOST_TT_COPY_REFERENCE_HPP_INCLUDED
  10. #include <boost/type_traits/add_lvalue_reference.hpp>
  11. #include <boost/type_traits/add_rvalue_reference.hpp>
  12. #include <boost/type_traits/is_lvalue_reference.hpp>
  13. #include <boost/type_traits/is_rvalue_reference.hpp>
  14. #include <boost/type_traits/conditional.hpp>
  15. namespace boost {
  16. template<class T, class U>
  17. struct copy_reference {
  18. typedef typename conditional<is_rvalue_reference<U>::value,
  19. typename add_rvalue_reference<T>::type,
  20. typename conditional<is_lvalue_reference<U>::value,
  21. typename add_lvalue_reference<T>::type, T>::type>::type type;
  22. };
  23. #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
  24. template<class T, class U>
  25. using copy_reference_t = typename copy_reference<T, U>::type;
  26. #endif
  27. } /* boost */
  28. #endif