add_volatile.hpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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_VOLATILE_HPP_INCLUDED
  9. #define BOOST_TT_ADD_VOLATILE_HPP_INCLUDED
  10. #include <boost/config.hpp>
  11. namespace boost {
  12. // * convert a type T to volatile type - add_volatile<T>
  13. // this is not required since the result is always
  14. // the same as "T volatile", but it does suppress warnings
  15. // from some compilers:
  16. #if defined(BOOST_MSVC)
  17. // This bogus warning will appear when add_volatile 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_volatile{ typedef T volatile type; };
  24. #if defined(BOOST_MSVC)
  25. # pragma warning(pop)
  26. #endif
  27. template <class T> struct add_volatile<T&>{ typedef T& type; };
  28. #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
  29. template <class T> using add_volatile_t = typename add_volatile<T>::type;
  30. #endif
  31. } // namespace boost
  32. #endif // BOOST_TT_ADD_VOLATILE_HPP_INCLUDED