add_const.hpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // (C) Copyright Dave Abrahams, Steve Cleary, Beman Dawes, Howard
  2. // Hinnant & John Maddock 2000.
  3. // Use, modification and distribution are subject to the Boost Software License,
  4. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt).
  6. //
  7. // See http://www.boost.org/libs/type_traits for most recent version including documentation.
  8. #ifndef BOOST_TT_ADD_CONST_HPP_INCLUDED
  9. #define BOOST_TT_ADD_CONST_HPP_INCLUDED
  10. #include <boost/type_traits/detail/config.hpp>
  11. namespace boost {
  12. // * convert a type T to const type - add_const<T>
  13. // this is not required since the result is always
  14. // the same as "T const", but it does suppress warnings
  15. // from some compilers:
  16. #if defined(BOOST_MSVC)
  17. // This bogus warning will appear when add_const is applied to a
  18. // const volatile reference because we can't detect const volatile
  19. // references with MSVC6.
  20. # pragma warning(push)
  21. # pragma warning(disable:4181) // warning C4181: qualifier applied to reference type ignored
  22. #endif
  23. template <class T> struct add_const
  24. {
  25. typedef T const type;
  26. };
  27. #if defined(BOOST_MSVC)
  28. # pragma warning(pop)
  29. #endif
  30. template <class T> struct add_const<T&>
  31. {
  32. typedef T& type;
  33. };
  34. #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
  35. template <class T> using add_const_t = typename add_const<T>::type;
  36. #endif
  37. } // namespace boost
  38. #endif // BOOST_TT_ADD_CONST_HPP_INCLUDED