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