1 | |
2 | // (C) Copyright Steve Cleary, Beman Dawes, Howard 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 | |
9 | #ifndef BOOST_TT_REMOVE_POINTER_HPP_INCLUDED |
10 | #define BOOST_TT_REMOVE_POINTER_HPP_INCLUDED |
11 | |
12 | #include <boost/config.hpp> |
13 | #include <boost/config/workaround.hpp> |
14 | |
15 | #if defined(BOOST_MSVC) |
16 | #include <boost/type_traits/remove_cv.hpp> |
17 | #include <boost/type_traits/is_pointer.hpp> |
18 | #endif |
19 | |
20 | namespace boost { |
21 | |
22 | #if BOOST_WORKAROUND(BOOST_MSVC, < 1900) |
23 | |
24 | namespace detail{ |
25 | |
26 | // |
27 | // We need all this crazy indirection because a type such as: |
28 | // |
29 | // T (*const)(U) |
30 | // |
31 | // Does not bind to a <T*> or <T*const> partial specialization with VC10 and earlier |
32 | // |
33 | template <class T> |
34 | struct remove_pointer_imp |
35 | { |
36 | typedef T type; |
37 | }; |
38 | |
39 | template <class T> |
40 | struct remove_pointer_imp<T*> |
41 | { |
42 | typedef T type; |
43 | }; |
44 | |
45 | template <class T, bool b> |
46 | struct remove_pointer_imp3 |
47 | { |
48 | typedef typename remove_pointer_imp<typename boost::remove_cv<T>::type>::type type; |
49 | }; |
50 | |
51 | template <class T> |
52 | struct remove_pointer_imp3<T, false> |
53 | { |
54 | typedef T type; |
55 | }; |
56 | |
57 | template <class T> |
58 | struct remove_pointer_imp2 |
59 | { |
60 | typedef typename remove_pointer_imp3<T, ::boost::is_pointer<T>::value>::type type; |
61 | }; |
62 | } |
63 | |
64 | template <class T> struct remove_pointer{ typedef typename boost::detail::remove_pointer_imp2<T>::type type; }; |
65 | |
66 | #else |
67 | |
68 | template <class T> struct remove_pointer{ typedef T type; }; |
69 | template <class T> struct remove_pointer<T*>{ typedef T type; }; |
70 | template <class T> struct remove_pointer<T*const>{ typedef T type; }; |
71 | template <class T> struct remove_pointer<T*volatile>{ typedef T type; }; |
72 | template <class T> struct remove_pointer<T*const volatile>{ typedef T type; }; |
73 | |
74 | #endif |
75 | |
76 | #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) |
77 | |
78 | template <class T> using remove_pointer_t = typename remove_pointer<T>::type; |
79 | |
80 | #endif |
81 | |
82 | } // namespace boost |
83 | |
84 | #endif // BOOST_TT_REMOVE_POINTER_HPP_INCLUDED |
85 | |