• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright David Abrahams 2004. Distributed under the Boost
2 // Software License, Version 1.0. (See accompanying
3 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4 //#include <stdio.h>
5 #define BOOST_ENABLE_ASSERT_HANDLER
6 #include <boost/assert.hpp>
7 #include <boost/mpl/assert.hpp>
8 #include <boost/python/detail/indirect_traits.hpp>
9 #include <boost/mpl/assert.hpp>
10 
11 //#define print(expr) printf("%s ==> %s\n", #expr, expr)
12 
13 // not all the compilers can handle an incomplete class type here.
14 struct X {};
15 
16 using namespace boost::python::indirect_traits;
17 
18 typedef void (X::*pmf)();
19 
20 BOOST_MPL_ASSERT((is_reference_to_function<int (&)()>));
21 BOOST_MPL_ASSERT_NOT((is_reference_to_function<int (*)()>));
22 BOOST_MPL_ASSERT_NOT((is_reference_to_function<int&>));
23 BOOST_MPL_ASSERT_NOT((is_reference_to_function<pmf>));
24 
25 BOOST_MPL_ASSERT_NOT((is_pointer_to_function<int (&)()>));
26 BOOST_MPL_ASSERT((is_pointer_to_function<int (*)()>));
27 BOOST_MPL_ASSERT_NOT((is_pointer_to_function<int (*&)()>));
28 BOOST_MPL_ASSERT_NOT((is_pointer_to_function<int (*const&)()>));
29 BOOST_MPL_ASSERT_NOT((is_pointer_to_function<pmf>));
30 
31 BOOST_MPL_ASSERT_NOT((is_reference_to_function_pointer<int (&)()>));
32 BOOST_MPL_ASSERT_NOT((is_reference_to_function_pointer<int (*)()>));
33 BOOST_MPL_ASSERT_NOT((is_reference_to_function_pointer<int&>));
34 BOOST_MPL_ASSERT((is_reference_to_function_pointer<int (*&)()>));
35 BOOST_MPL_ASSERT((is_reference_to_function_pointer<int (*const&)()>));
36 BOOST_MPL_ASSERT_NOT((is_reference_to_function_pointer<pmf>));
37 
38 BOOST_MPL_ASSERT((is_reference_to_pointer<int*&>));
39 BOOST_MPL_ASSERT((is_reference_to_pointer<int* const&>));
40 BOOST_MPL_ASSERT((is_reference_to_pointer<int*volatile&>));
41 BOOST_MPL_ASSERT((is_reference_to_pointer<int*const volatile&>));
42 BOOST_MPL_ASSERT((is_reference_to_pointer<int const*&>));
43 BOOST_MPL_ASSERT((is_reference_to_pointer<int const* const&>));
44 BOOST_MPL_ASSERT((is_reference_to_pointer<int const*volatile&>));
45 BOOST_MPL_ASSERT((is_reference_to_pointer<int const*const volatile&>));
46 BOOST_MPL_ASSERT_NOT((is_reference_to_pointer<pmf>));
47 
48 BOOST_MPL_ASSERT_NOT((is_reference_to_pointer<int const volatile>));
49 BOOST_MPL_ASSERT_NOT((is_reference_to_pointer<int>));
50 BOOST_MPL_ASSERT_NOT((is_reference_to_pointer<int*>));
51 
52 BOOST_MPL_ASSERT_NOT((is_reference_to_const<int*&>));
53 BOOST_MPL_ASSERT((is_reference_to_const<int* const&>));
54 BOOST_MPL_ASSERT_NOT((is_reference_to_const<int*volatile&>));
55 BOOST_MPL_ASSERT((is_reference_to_const<int*const volatile&>));
56 
57 BOOST_MPL_ASSERT_NOT((is_reference_to_const<int const volatile>));
58 BOOST_MPL_ASSERT_NOT((is_reference_to_const<int>));
59 BOOST_MPL_ASSERT_NOT((is_reference_to_const<int*>));
60 
61 BOOST_MPL_ASSERT((is_reference_to_non_const<int*&>));
62 BOOST_MPL_ASSERT_NOT((is_reference_to_non_const<int* const&>));
63 BOOST_MPL_ASSERT((is_reference_to_non_const<int*volatile&>));
64 BOOST_MPL_ASSERT_NOT((is_reference_to_non_const<int*const volatile&>));
65 
66 BOOST_MPL_ASSERT_NOT((is_reference_to_non_const<int const volatile>));
67 BOOST_MPL_ASSERT_NOT((is_reference_to_non_const<int>));
68 BOOST_MPL_ASSERT_NOT((is_reference_to_non_const<int*>));
69 
70 BOOST_MPL_ASSERT_NOT((is_reference_to_volatile<int*&>));
71 BOOST_MPL_ASSERT_NOT((is_reference_to_volatile<int* const&>));
72 BOOST_MPL_ASSERT((is_reference_to_volatile<int*volatile&>));
73 BOOST_MPL_ASSERT((is_reference_to_volatile<int*const volatile&>));
74 
75 BOOST_MPL_ASSERT_NOT((is_reference_to_volatile<int const volatile>));
76 BOOST_MPL_ASSERT_NOT((is_reference_to_volatile<int>));
77 BOOST_MPL_ASSERT_NOT((is_reference_to_volatile<int*>));
78 
79 namespace tt = boost::python::indirect_traits;
80 
81 BOOST_MPL_ASSERT_NOT((tt::is_reference_to_class<int>));
82 BOOST_MPL_ASSERT_NOT((tt::is_reference_to_class<int&>));
83 BOOST_MPL_ASSERT_NOT((tt::is_reference_to_class<int*>));
84 
85 
86 BOOST_MPL_ASSERT_NOT((tt::is_reference_to_class<pmf>));
87 BOOST_MPL_ASSERT_NOT((tt::is_reference_to_class<pmf const&>));
88 
89 BOOST_MPL_ASSERT_NOT((tt::is_reference_to_class<X>));
90 
91 BOOST_MPL_ASSERT((tt::is_reference_to_class<X&>));
92 BOOST_MPL_ASSERT((tt::is_reference_to_class<X const&>));
93 BOOST_MPL_ASSERT((tt::is_reference_to_class<X volatile&>));
94 BOOST_MPL_ASSERT((tt::is_reference_to_class<X const volatile&>));
95 
96 BOOST_MPL_ASSERT_NOT((is_pointer_to_class<int>));
97 BOOST_MPL_ASSERT_NOT((is_pointer_to_class<int*>));
98 BOOST_MPL_ASSERT_NOT((is_pointer_to_class<int&>));
99 
100 BOOST_MPL_ASSERT_NOT((is_pointer_to_class<X>));
101 BOOST_MPL_ASSERT_NOT((is_pointer_to_class<X&>));
102 BOOST_MPL_ASSERT_NOT((is_pointer_to_class<pmf>));
103 BOOST_MPL_ASSERT_NOT((is_pointer_to_class<pmf const>));
104 BOOST_MPL_ASSERT((is_pointer_to_class<X*>));
105 BOOST_MPL_ASSERT((is_pointer_to_class<X const*>));
106 BOOST_MPL_ASSERT((is_pointer_to_class<X volatile*>));
107 BOOST_MPL_ASSERT((is_pointer_to_class<X const volatile*>));
108 
109 BOOST_MPL_ASSERT((tt::is_reference_to_member_function_pointer<pmf&>));
110 BOOST_MPL_ASSERT((tt::is_reference_to_member_function_pointer<pmf const&>));
111 BOOST_MPL_ASSERT((tt::is_reference_to_member_function_pointer<pmf volatile&>));
112 BOOST_MPL_ASSERT((tt::is_reference_to_member_function_pointer<pmf const volatile&>));
113 BOOST_MPL_ASSERT_NOT((tt::is_reference_to_member_function_pointer<pmf[2]>));
114 BOOST_MPL_ASSERT_NOT((tt::is_reference_to_member_function_pointer<pmf(&)[2]>));
115 BOOST_MPL_ASSERT_NOT((tt::is_reference_to_member_function_pointer<pmf>));
116 
117