7c8f76b09d41e1ef617e0c7fde8d5185a610f091
[platform/upstream/boost.git] / boost / detail / indirect_traits.hpp
1 // Copyright David Abrahams 2002.
2 // Distributed under the Boost Software License, Version 1.0. (See
3 // accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
5 #ifndef INDIRECT_TRAITS_DWA2002131_HPP
6 # define INDIRECT_TRAITS_DWA2002131_HPP
7 # include <boost/type_traits/is_function.hpp>
8 # include <boost/type_traits/is_reference.hpp>
9 # include <boost/type_traits/is_pointer.hpp>
10 # include <boost/type_traits/is_class.hpp>
11 # include <boost/type_traits/is_const.hpp>
12 # include <boost/type_traits/is_volatile.hpp>
13 # include <boost/type_traits/is_member_function_pointer.hpp>
14 # include <boost/type_traits/is_member_pointer.hpp>
15 # include <boost/type_traits/remove_cv.hpp>
16 # include <boost/type_traits/remove_reference.hpp>
17 # include <boost/type_traits/remove_pointer.hpp>
18
19 # include <boost/type_traits/detail/ice_and.hpp>
20 # include <boost/detail/workaround.hpp>
21
22 # include <boost/mpl/eval_if.hpp>
23 # include <boost/mpl/if.hpp>
24 # include <boost/mpl/bool.hpp>
25 # include <boost/mpl/and.hpp>
26 # include <boost/mpl/not.hpp>
27 # include <boost/mpl/aux_/lambda_support.hpp>
28
29
30 namespace boost { namespace detail {
31
32 namespace indirect_traits {
33
34 template <class T>
35 struct is_reference_to_const : mpl::false_
36 {
37 };
38
39 template <class T>
40 struct is_reference_to_const<T const&> : mpl::true_
41 {
42 };
43
44 #   if defined(BOOST_MSVC) && _MSC_FULL_VER <= 13102140 // vc7.01 alpha workaround
45 template<class T>
46 struct is_reference_to_const<T const volatile&> : mpl::true_
47 {
48 };
49 #   endif 
50
51 template <class T>
52 struct is_reference_to_function : mpl::false_
53 {
54 };
55
56 template <class T>
57 struct is_reference_to_function<T&> : is_function<T>
58 {
59 };
60
61 template <class T>
62 struct is_pointer_to_function : mpl::false_
63 {
64 };
65
66 // There's no such thing as a pointer-to-cv-function, so we don't need
67 // specializations for those
68 template <class T>
69 struct is_pointer_to_function<T*> : is_function<T>
70 {
71 };
72
73 template <class T>
74 struct is_reference_to_member_function_pointer_impl : mpl::false_
75 {
76 };
77
78 template <class T>
79 struct is_reference_to_member_function_pointer_impl<T&>
80     : is_member_function_pointer<typename remove_cv<T>::type>
81 {
82 };
83
84
85 template <class T>
86 struct is_reference_to_member_function_pointer
87     : is_reference_to_member_function_pointer_impl<T>
88 {
89     BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_reference_to_member_function_pointer,(T))
90 };
91
92 template <class T>
93 struct is_reference_to_function_pointer_aux
94     : mpl::and_<
95           is_reference<T>
96         , is_pointer_to_function<
97               typename remove_cv<
98                   typename remove_reference<T>::type
99               >::type
100           >
101       >
102 {
103     // There's no such thing as a pointer-to-cv-function, so we don't need specializations for those
104 };
105
106 template <class T>
107 struct is_reference_to_function_pointer
108     : mpl::if_<
109           is_reference_to_function<T>
110         , mpl::false_
111         , is_reference_to_function_pointer_aux<T>
112      >::type
113 {
114 };
115
116 template <class T>
117 struct is_reference_to_non_const
118     : mpl::and_<
119           is_reference<T>
120         , mpl::not_<
121              is_reference_to_const<T>
122           >
123       >
124 {
125 };
126
127 template <class T>
128 struct is_reference_to_volatile : mpl::false_
129 {
130 };
131
132 template <class T>
133 struct is_reference_to_volatile<T volatile&> : mpl::true_
134 {
135 };
136
137 #   if defined(BOOST_MSVC) && _MSC_FULL_VER <= 13102140 // vc7.01 alpha workaround
138 template <class T>
139 struct is_reference_to_volatile<T const volatile&> : mpl::true_
140 {
141 };
142 #   endif 
143
144
145 template <class T>
146 struct is_reference_to_pointer : mpl::false_
147 {
148 };
149
150 template <class T>
151 struct is_reference_to_pointer<T*&> : mpl::true_
152 {
153 };
154
155 template <class T>
156 struct is_reference_to_pointer<T* const&> : mpl::true_
157 {
158 };
159
160 template <class T>
161 struct is_reference_to_pointer<T* volatile&> : mpl::true_
162 {
163 };
164
165 template <class T>
166 struct is_reference_to_pointer<T* const volatile&> : mpl::true_
167 {
168 };
169
170 template <class T>
171 struct is_reference_to_class
172     : mpl::and_<
173           is_reference<T>
174         , is_class<
175               typename remove_cv<
176                   typename remove_reference<T>::type
177               >::type
178           >
179       >
180 {
181     BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_reference_to_class,(T))
182 };
183
184 template <class T>
185 struct is_pointer_to_class
186     : mpl::and_<
187           is_pointer<T>
188         , is_class<
189               typename remove_cv<
190                   typename remove_pointer<T>::type
191               >::type
192           >
193       >
194 {
195     BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_pointer_to_class,(T))
196 };
197
198
199 }
200
201 using namespace indirect_traits;
202
203 }} // namespace boost::python::detail
204
205 #endif // INDIRECT_TRAITS_DWA2002131_HPP