add_pointer.hpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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_POINTER_HPP_INCLUDED
  8. #define BOOST_TT_ADD_POINTER_HPP_INCLUDED
  9. #include <boost/type_traits/remove_reference.hpp>
  10. namespace boost {
  11. #if defined(__BORLANDC__) && (__BORLANDC__ < 0x5A0)
  12. //
  13. // For some reason this implementation stops Borlands compiler
  14. // from dropping cv-qualifiers, it still fails with references
  15. // to arrays for some reason though (shrug...) (JM 20021104)
  16. //
  17. template <typename T>
  18. struct add_pointer
  19. {
  20. typedef T* type;
  21. };
  22. template <typename T>
  23. struct add_pointer<T&>
  24. {
  25. typedef T* type;
  26. };
  27. template <typename T>
  28. struct add_pointer<T&const>
  29. {
  30. typedef T* type;
  31. };
  32. template <typename T>
  33. struct add_pointer<T&volatile>
  34. {
  35. typedef T* type;
  36. };
  37. template <typename T>
  38. struct add_pointer<T&const volatile>
  39. {
  40. typedef T* type;
  41. };
  42. #else
  43. template <typename T>
  44. struct add_pointer
  45. {
  46. typedef typename remove_reference<T>::type no_ref_type;
  47. typedef no_ref_type* type;
  48. };
  49. #endif
  50. #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
  51. template <class T> using add_pointer_t = typename add_pointer<T>::type;
  52. #endif
  53. } // namespace boost
  54. #endif // BOOST_TT_ADD_POINTER_HPP_INCLUDED