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>
19 # include <boost/type_traits/detail/ice_and.hpp>
20 # include <boost/detail/workaround.hpp>
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>
29 # ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
30 # include <boost/detail/is_function_ref_tester.hpp>
33 namespace boost
{ namespace detail
{
35 namespace indirect_traits
{
37 # ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
39 struct is_reference_to_const
: mpl::false_
44 struct is_reference_to_const
<T
const&> : mpl::true_
48 # if defined(BOOST_MSVC) && _MSC_FULL_VER <= 13102140 // vc7.01 alpha workaround
50 struct is_reference_to_const
<T
const volatile&> : mpl::true_
56 struct is_reference_to_function
: mpl::false_
61 struct is_reference_to_function
<T
&> : is_function
<T
>
66 struct is_pointer_to_function
: mpl::false_
70 // There's no such thing as a pointer-to-cv-function, so we don't need
71 // specializations for those
73 struct is_pointer_to_function
<T
*> : is_function
<T
>
78 struct is_reference_to_member_function_pointer_impl
: mpl::false_
83 struct is_reference_to_member_function_pointer_impl
<T
&>
84 : is_member_function_pointer
<typename remove_cv
<T
>::type
>
90 struct is_reference_to_member_function_pointer
91 : is_reference_to_member_function_pointer_impl
<T
>
93 BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_reference_to_member_function_pointer
,(T
))
97 struct is_reference_to_function_pointer_aux
100 , is_pointer_to_function
<
102 typename remove_reference
<T
>::type
107 // There's no such thing as a pointer-to-cv-function, so we don't need specializations for those
111 struct is_reference_to_function_pointer
113 is_reference_to_function
<T
>
115 , is_reference_to_function_pointer_aux
<T
>
121 struct is_reference_to_non_const
125 is_reference_to_const
<T
>
132 struct is_reference_to_volatile
: mpl::false_
137 struct is_reference_to_volatile
<T
volatile&> : mpl::true_
141 # if defined(BOOST_MSVC) && _MSC_FULL_VER <= 13102140 // vc7.01 alpha workaround
143 struct is_reference_to_volatile
<T
const volatile&> : mpl::true_
150 struct is_reference_to_pointer
: mpl::false_
155 struct is_reference_to_pointer
<T
*&> : mpl::true_
160 struct is_reference_to_pointer
<T
* const&> : mpl::true_
165 struct is_reference_to_pointer
<T
* volatile&> : mpl::true_
170 struct is_reference_to_pointer
<T
* const volatile&> : mpl::true_
175 struct is_reference_to_class
180 typename remove_reference
<T
>::type
185 BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_reference_to_class
,(T
))
189 struct is_pointer_to_class
194 typename remove_pointer
<T
>::type
199 BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_pointer_to_class
,(T
))
204 using namespace boost::detail::is_function_ref_tester_
;
206 typedef char (&inner_yes_type
)[3];
207 typedef char (&inner_no_type
)[2];
208 typedef char (&outer_no_type
)[1];
210 template <typename V
>
213 typedef typename
mpl::if_
<
220 template <typename V
>
221 struct is_volatile_help
223 typedef typename
mpl::if_
<
230 template <typename V
>
231 struct is_pointer_help
233 typedef typename
mpl::if_
<
240 template <typename V
>
243 typedef typename
mpl::if_
<
251 struct is_reference_to_function_aux
254 BOOST_STATIC_CONSTANT(
255 bool, value
= sizeof(detail::is_function_ref_tester(t
,0)) == sizeof(::boost::type_traits::yes_type
));
256 typedef mpl::bool_
<value
> type
;
260 struct is_reference_to_function
261 : mpl::if_
<is_reference
<T
>, is_reference_to_function_aux
<T
>, mpl::bool_
<false> >::type
266 struct is_pointer_to_function_aux
269 BOOST_STATIC_CONSTANT(
271 = sizeof(::boost::type_traits::is_function_ptr_tester(t
)) == sizeof(::boost::type_traits::yes_type
));
272 typedef mpl::bool_
<value
> type
;
276 struct is_pointer_to_function
277 : mpl::if_
<is_pointer
<T
>, is_pointer_to_function_aux
<T
>, mpl::bool_
<false> >::type
279 BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_pointer_to_function
,(T
))
285 struct apply
: mpl::false_
290 template <typename V
>
291 typename is_const_help
<V
>::type
reference_to_const_helper(V
&);
293 reference_to_const_helper(...);
301 BOOST_STATIC_CONSTANT(
303 = sizeof(reference_to_const_helper(t
)) == sizeof(inner_yes_type
));
304 typedef mpl::bool_
<value
> type
;
308 template <bool ref
= true>
309 struct is_reference_to_const_helper1
: true_helper1
314 struct is_reference_to_const_helper1
<false> : false_helper1
320 struct is_reference_to_const
321 : is_reference_to_const_helper1
<is_reference
<T
>::value
>::template apply
<T
>
326 template <bool ref
= true>
327 struct is_reference_to_non_const_helper1
333 BOOST_STATIC_CONSTANT(
335 = sizeof(reference_to_const_helper(t
)) == sizeof(inner_no_type
));
337 typedef mpl::bool_
<value
> type
;
342 struct is_reference_to_non_const_helper1
<false> : false_helper1
348 struct is_reference_to_non_const
349 : is_reference_to_non_const_helper1
<is_reference
<T
>::value
>::template apply
<T
>
351 BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_reference_to_non_const
,(T
))
355 template <typename V
>
356 typename is_volatile_help
<V
>::type
reference_to_volatile_helper(V
&);
358 reference_to_volatile_helper(...);
360 template <bool ref
= true>
361 struct is_reference_to_volatile_helper1
367 BOOST_STATIC_CONSTANT(
369 = sizeof(reference_to_volatile_helper(t
)) == sizeof(inner_yes_type
));
370 typedef mpl::bool_
<value
> type
;
375 struct is_reference_to_volatile_helper1
<false> : false_helper1
381 struct is_reference_to_volatile
382 : is_reference_to_volatile_helper1
<is_reference
<T
>::value
>::template apply
<T
>
386 template <typename V
>
387 typename is_pointer_help
<V
>::type
reference_to_pointer_helper(V
&);
388 outer_no_type
reference_to_pointer_helper(...);
391 struct reference_to_pointer_impl
394 BOOST_STATIC_CONSTANT(
396 = (sizeof((reference_to_pointer_helper
)(t
)) == sizeof(inner_yes_type
))
399 typedef mpl::bool_
<value
> type
;
403 struct is_reference_to_pointer
404 : mpl::eval_if
<is_reference
<T
>, reference_to_pointer_impl
<T
>, mpl::false_
>::type
406 BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_reference_to_pointer
,(T
))
410 struct is_reference_to_function_pointer
411 : mpl::eval_if
<is_reference
<T
>, is_pointer_to_function_aux
<T
>, mpl::false_
>::type
413 BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_reference_to_function_pointer
,(T
))
418 struct is_member_function_pointer_help
419 : mpl::if_
<is_member_function_pointer
<T
>, inner_yes_type
, inner_no_type
>
422 template <typename V
>
423 typename is_member_function_pointer_help
<V
>::type
member_function_pointer_helper(V
&);
424 outer_no_type
member_function_pointer_helper(...);
427 struct is_pointer_to_member_function_aux
430 BOOST_STATIC_CONSTANT(
432 = sizeof((member_function_pointer_helper
)(t
)) == sizeof(inner_yes_type
));
433 typedef mpl::bool_
<value
> type
;
437 struct is_reference_to_member_function_pointer
440 , is_pointer_to_member_function_aux
<T
>
444 BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_reference_to_member_function_pointer
,(T
))
447 template <typename V
>
448 typename is_class_help
<V
>::type
reference_to_class_helper(V
const volatile&);
449 outer_no_type
reference_to_class_helper(...);
452 struct is_reference_to_class
455 BOOST_STATIC_CONSTANT(
457 = (is_reference
<T
>::value
458 & (sizeof(reference_to_class_helper(t
)) == sizeof(inner_yes_type
)))
460 typedef mpl::bool_
<value
> type
;
461 BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_reference_to_class
,(T
))
464 template <typename V
>
465 typename is_class_help
<V
>::type
pointer_to_class_helper(V
const volatile*);
466 outer_no_type
pointer_to_class_helper(...);
469 struct is_pointer_to_class
472 BOOST_STATIC_CONSTANT(
474 = (is_pointer
<T
>::value
475 && sizeof(pointer_to_class_helper(t
)) == sizeof(inner_yes_type
))
477 typedef mpl::bool_
<value
> type
;
479 # endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
483 using namespace indirect_traits
;
485 }} // namespace boost::python::detail
487 #endif // INDIRECT_TRAITS_DWA2002131_HPP