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