remove_pointer.hpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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_REMOVE_POINTER_HPP_INCLUDED
  8. #define BOOST_TT_REMOVE_POINTER_HPP_INCLUDED
  9. #include <boost/config.hpp>
  10. #include <boost/config/workaround.hpp>
  11. #if defined(BOOST_MSVC)
  12. #include <boost/type_traits/remove_cv.hpp>
  13. #include <boost/type_traits/is_pointer.hpp>
  14. #endif
  15. namespace boost {
  16. #if BOOST_WORKAROUND(BOOST_MSVC, < 1900)
  17. namespace detail{
  18. //
  19. // We need all this crazy indirection because a type such as:
  20. //
  21. // T (*const)(U)
  22. //
  23. // Does not bind to a <T*> or <T*const> partial specialization with VC10 and earlier
  24. //
  25. template <class T>
  26. struct remove_pointer_imp
  27. {
  28. typedef T type;
  29. };
  30. template <class T>
  31. struct remove_pointer_imp<T*>
  32. {
  33. typedef T type;
  34. };
  35. template <class T, bool b>
  36. struct remove_pointer_imp3
  37. {
  38. typedef typename remove_pointer_imp<typename boost::remove_cv<T>::type>::type type;
  39. };
  40. template <class T>
  41. struct remove_pointer_imp3<T, false>
  42. {
  43. typedef T type;
  44. };
  45. template <class T>
  46. struct remove_pointer_imp2
  47. {
  48. typedef typename remove_pointer_imp3<T, ::boost::is_pointer<T>::value>::type type;
  49. };
  50. }
  51. template <class T> struct remove_pointer{ typedef typename boost::detail::remove_pointer_imp2<T>::type type; };
  52. #else
  53. template <class T> struct remove_pointer{ typedef T type; };
  54. template <class T> struct remove_pointer<T*>{ typedef T type; };
  55. template <class T> struct remove_pointer<T*const>{ typedef T type; };
  56. template <class T> struct remove_pointer<T*volatile>{ typedef T type; };
  57. template <class T> struct remove_pointer<T*const volatile>{ typedef T type; };
  58. #endif
  59. #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
  60. template <class T> using remove_pointer_t = typename remove_pointer<T>::type;
  61. #endif
  62. } // namespace boost
  63. #endif // BOOST_TT_REMOVE_POINTER_HPP_INCLUDED