copy_cv.hpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #ifndef BOOST_TYPE_TRAITS_COPY_CV_HPP_INCLUDED
  2. #define BOOST_TYPE_TRAITS_COPY_CV_HPP_INCLUDED
  3. //
  4. // Copyright 2015 Peter Dimov
  5. //
  6. // Distributed under the Boost Software License, Version 1.0.
  7. // See accompanying file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt
  9. //
  10. #include <boost/type_traits/is_const.hpp>
  11. #include <boost/type_traits/is_volatile.hpp>
  12. #include <boost/type_traits/add_const.hpp>
  13. #include <boost/type_traits/add_volatile.hpp>
  14. #include <boost/type_traits/conditional.hpp>
  15. namespace boost
  16. {
  17. template<class T, class U> struct copy_cv
  18. {
  19. private:
  20. typedef typename boost::conditional<boost::is_const<U>::value, typename boost::add_const<T>::type, T>::type CT;
  21. public:
  22. typedef typename boost::conditional<boost::is_volatile<U>::value, typename boost::add_volatile<CT>::type, CT>::type type;
  23. };
  24. #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
  25. template <class T, class U> using copy_cv_t = typename copy_cv<T, U>::type;
  26. #endif
  27. } // namespace boost
  28. #endif // #ifndef BOOST_TYPE_TRAITS_COPY_CV_HPP_INCLUDED