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/type_traits/is_member_function_pointer.hpp> |
---|
8 | #include <boost/mpl/assert.hpp> |
---|
9 | #include <boost/python/detail/indirect_traits.hpp> |
---|
10 | #include <boost/mpl/assert.hpp> |
---|
11 | |
---|
12 | //#define print(expr) printf("%s ==> %s\n", #expr, expr) |
---|
13 | |
---|
14 | // not all the compilers can handle an incomplete class type here. |
---|
15 | struct X {}; |
---|
16 | |
---|
17 | using namespace boost::python::indirect_traits; |
---|
18 | |
---|
19 | typedef void (X::*pmf)(); |
---|
20 | |
---|
21 | BOOST_MPL_ASSERT((is_reference_to_function<int (&)()>)); |
---|
22 | BOOST_MPL_ASSERT_NOT((is_reference_to_function<int (*)()>)); |
---|
23 | BOOST_MPL_ASSERT_NOT((is_reference_to_function<int&>)); |
---|
24 | BOOST_MPL_ASSERT_NOT((is_reference_to_function<pmf>)); |
---|
25 | |
---|
26 | BOOST_MPL_ASSERT_NOT((is_pointer_to_function<int (&)()>)); |
---|
27 | BOOST_MPL_ASSERT((is_pointer_to_function<int (*)()>)); |
---|
28 | BOOST_MPL_ASSERT_NOT((is_pointer_to_function<int (*&)()>)); |
---|
29 | BOOST_MPL_ASSERT_NOT((is_pointer_to_function<int (*const&)()>)); |
---|
30 | BOOST_MPL_ASSERT_NOT((is_pointer_to_function<pmf>)); |
---|
31 | |
---|
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_NOT((is_reference_to_function_pointer<int&>)); |
---|
35 | BOOST_MPL_ASSERT((is_reference_to_function_pointer<int (*&)()>)); |
---|
36 | BOOST_MPL_ASSERT((is_reference_to_function_pointer<int (*const&)()>)); |
---|
37 | BOOST_MPL_ASSERT_NOT((is_reference_to_function_pointer<pmf>)); |
---|
38 | |
---|
39 | BOOST_MPL_ASSERT((is_reference_to_pointer<int*&>)); |
---|
40 | BOOST_MPL_ASSERT((is_reference_to_pointer<int* const&>)); |
---|
41 | BOOST_MPL_ASSERT((is_reference_to_pointer<int*volatile&>)); |
---|
42 | BOOST_MPL_ASSERT((is_reference_to_pointer<int*const volatile&>)); |
---|
43 | BOOST_MPL_ASSERT((is_reference_to_pointer<int const*&>)); |
---|
44 | BOOST_MPL_ASSERT((is_reference_to_pointer<int const* const&>)); |
---|
45 | BOOST_MPL_ASSERT((is_reference_to_pointer<int const*volatile&>)); |
---|
46 | BOOST_MPL_ASSERT((is_reference_to_pointer<int const*const volatile&>)); |
---|
47 | BOOST_MPL_ASSERT_NOT((is_reference_to_pointer<pmf>)); |
---|
48 | |
---|
49 | BOOST_MPL_ASSERT_NOT((is_reference_to_pointer<int const volatile>)); |
---|
50 | BOOST_MPL_ASSERT_NOT((is_reference_to_pointer<int>)); |
---|
51 | BOOST_MPL_ASSERT_NOT((is_reference_to_pointer<int*>)); |
---|
52 | |
---|
53 | BOOST_MPL_ASSERT_NOT((is_reference_to_const<int*&>)); |
---|
54 | BOOST_MPL_ASSERT((is_reference_to_const<int* const&>)); |
---|
55 | BOOST_MPL_ASSERT_NOT((is_reference_to_const<int*volatile&>)); |
---|
56 | BOOST_MPL_ASSERT((is_reference_to_const<int*const volatile&>)); |
---|
57 | |
---|
58 | BOOST_MPL_ASSERT_NOT((is_reference_to_const<int const volatile>)); |
---|
59 | BOOST_MPL_ASSERT_NOT((is_reference_to_const<int>)); |
---|
60 | BOOST_MPL_ASSERT_NOT((is_reference_to_const<int*>)); |
---|
61 | |
---|
62 | BOOST_MPL_ASSERT((is_reference_to_non_const<int*&>)); |
---|
63 | BOOST_MPL_ASSERT_NOT((is_reference_to_non_const<int* const&>)); |
---|
64 | BOOST_MPL_ASSERT((is_reference_to_non_const<int*volatile&>)); |
---|
65 | BOOST_MPL_ASSERT_NOT((is_reference_to_non_const<int*const volatile&>)); |
---|
66 | |
---|
67 | BOOST_MPL_ASSERT_NOT((is_reference_to_non_const<int const volatile>)); |
---|
68 | BOOST_MPL_ASSERT_NOT((is_reference_to_non_const<int>)); |
---|
69 | BOOST_MPL_ASSERT_NOT((is_reference_to_non_const<int*>)); |
---|
70 | |
---|
71 | BOOST_MPL_ASSERT_NOT((is_reference_to_volatile<int*&>)); |
---|
72 | BOOST_MPL_ASSERT_NOT((is_reference_to_volatile<int* const&>)); |
---|
73 | BOOST_MPL_ASSERT((is_reference_to_volatile<int*volatile&>)); |
---|
74 | BOOST_MPL_ASSERT((is_reference_to_volatile<int*const volatile&>)); |
---|
75 | |
---|
76 | BOOST_MPL_ASSERT_NOT((is_reference_to_volatile<int const volatile>)); |
---|
77 | BOOST_MPL_ASSERT_NOT((is_reference_to_volatile<int>)); |
---|
78 | BOOST_MPL_ASSERT_NOT((is_reference_to_volatile<int*>)); |
---|
79 | |
---|
80 | namespace tt = boost::python::indirect_traits; |
---|
81 | |
---|
82 | BOOST_MPL_ASSERT_NOT((tt::is_reference_to_class<int>)); |
---|
83 | BOOST_MPL_ASSERT_NOT((tt::is_reference_to_class<int&>)); |
---|
84 | BOOST_MPL_ASSERT_NOT((tt::is_reference_to_class<int*>)); |
---|
85 | |
---|
86 | |
---|
87 | BOOST_MPL_ASSERT_NOT((tt::is_reference_to_class<pmf>)); |
---|
88 | BOOST_MPL_ASSERT_NOT((tt::is_reference_to_class<pmf const&>)); |
---|
89 | |
---|
90 | BOOST_MPL_ASSERT_NOT((tt::is_reference_to_class<X>)); |
---|
91 | |
---|
92 | BOOST_MPL_ASSERT((tt::is_reference_to_class<X&>)); |
---|
93 | BOOST_MPL_ASSERT((tt::is_reference_to_class<X const&>)); |
---|
94 | BOOST_MPL_ASSERT((tt::is_reference_to_class<X volatile&>)); |
---|
95 | BOOST_MPL_ASSERT((tt::is_reference_to_class<X const volatile&>)); |
---|
96 | |
---|
97 | BOOST_MPL_ASSERT_NOT((is_pointer_to_class<int>)); |
---|
98 | BOOST_MPL_ASSERT_NOT((is_pointer_to_class<int*>)); |
---|
99 | BOOST_MPL_ASSERT_NOT((is_pointer_to_class<int&>)); |
---|
100 | |
---|
101 | BOOST_MPL_ASSERT_NOT((is_pointer_to_class<X>)); |
---|
102 | BOOST_MPL_ASSERT_NOT((is_pointer_to_class<X&>)); |
---|
103 | BOOST_MPL_ASSERT_NOT((is_pointer_to_class<pmf>)); |
---|
104 | BOOST_MPL_ASSERT_NOT((is_pointer_to_class<pmf const>)); |
---|
105 | BOOST_MPL_ASSERT((is_pointer_to_class<X*>)); |
---|
106 | BOOST_MPL_ASSERT((is_pointer_to_class<X const*>)); |
---|
107 | BOOST_MPL_ASSERT((is_pointer_to_class<X volatile*>)); |
---|
108 | BOOST_MPL_ASSERT((is_pointer_to_class<X const volatile*>)); |
---|
109 | |
---|
110 | BOOST_MPL_ASSERT((tt::is_reference_to_member_function_pointer<pmf&>)); |
---|
111 | BOOST_MPL_ASSERT((tt::is_reference_to_member_function_pointer<pmf const&>)); |
---|
112 | BOOST_MPL_ASSERT((tt::is_reference_to_member_function_pointer<pmf volatile&>)); |
---|
113 | BOOST_MPL_ASSERT((tt::is_reference_to_member_function_pointer<pmf const volatile&>)); |
---|
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(&)[2]>)); |
---|
116 | BOOST_MPL_ASSERT_NOT((tt::is_reference_to_member_function_pointer<pmf>)); |
---|
117 | |
---|