Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/python/test/indirect_traits_test.cpp @ 29

Last change on this file since 29 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 5.3 KB
Line 
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.
15struct X {};
16
17using namespace boost::python::indirect_traits;
18
19typedef void (X::*pmf)();
20
21BOOST_MPL_ASSERT((is_reference_to_function<int (&)()>));
22BOOST_MPL_ASSERT_NOT((is_reference_to_function<int (*)()>));
23BOOST_MPL_ASSERT_NOT((is_reference_to_function<int&>));
24BOOST_MPL_ASSERT_NOT((is_reference_to_function<pmf>));
25   
26BOOST_MPL_ASSERT_NOT((is_pointer_to_function<int (&)()>));
27BOOST_MPL_ASSERT((is_pointer_to_function<int (*)()>));
28BOOST_MPL_ASSERT_NOT((is_pointer_to_function<int (*&)()>));
29BOOST_MPL_ASSERT_NOT((is_pointer_to_function<int (*const&)()>));
30BOOST_MPL_ASSERT_NOT((is_pointer_to_function<pmf>));
31   
32BOOST_MPL_ASSERT_NOT((is_reference_to_function_pointer<int (&)()>));
33BOOST_MPL_ASSERT_NOT((is_reference_to_function_pointer<int (*)()>));
34BOOST_MPL_ASSERT_NOT((is_reference_to_function_pointer<int&>));
35BOOST_MPL_ASSERT((is_reference_to_function_pointer<int (*&)()>));
36BOOST_MPL_ASSERT((is_reference_to_function_pointer<int (*const&)()>));
37BOOST_MPL_ASSERT_NOT((is_reference_to_function_pointer<pmf>));
38
39BOOST_MPL_ASSERT((is_reference_to_pointer<int*&>));
40BOOST_MPL_ASSERT((is_reference_to_pointer<int* const&>));
41BOOST_MPL_ASSERT((is_reference_to_pointer<int*volatile&>));
42BOOST_MPL_ASSERT((is_reference_to_pointer<int*const volatile&>));
43BOOST_MPL_ASSERT((is_reference_to_pointer<int const*&>));
44BOOST_MPL_ASSERT((is_reference_to_pointer<int const* const&>));
45BOOST_MPL_ASSERT((is_reference_to_pointer<int const*volatile&>));
46BOOST_MPL_ASSERT((is_reference_to_pointer<int const*const volatile&>));
47BOOST_MPL_ASSERT_NOT((is_reference_to_pointer<pmf>));
48
49BOOST_MPL_ASSERT_NOT((is_reference_to_pointer<int const volatile>));
50BOOST_MPL_ASSERT_NOT((is_reference_to_pointer<int>));
51BOOST_MPL_ASSERT_NOT((is_reference_to_pointer<int*>));
52
53BOOST_MPL_ASSERT_NOT((is_reference_to_const<int*&>));
54BOOST_MPL_ASSERT((is_reference_to_const<int* const&>));
55BOOST_MPL_ASSERT_NOT((is_reference_to_const<int*volatile&>));
56BOOST_MPL_ASSERT((is_reference_to_const<int*const volatile&>));
57   
58BOOST_MPL_ASSERT_NOT((is_reference_to_const<int const volatile>));
59BOOST_MPL_ASSERT_NOT((is_reference_to_const<int>));
60BOOST_MPL_ASSERT_NOT((is_reference_to_const<int*>));
61
62BOOST_MPL_ASSERT((is_reference_to_non_const<int*&>));
63BOOST_MPL_ASSERT_NOT((is_reference_to_non_const<int* const&>));
64BOOST_MPL_ASSERT((is_reference_to_non_const<int*volatile&>));
65BOOST_MPL_ASSERT_NOT((is_reference_to_non_const<int*const volatile&>));
66   
67BOOST_MPL_ASSERT_NOT((is_reference_to_non_const<int const volatile>));
68BOOST_MPL_ASSERT_NOT((is_reference_to_non_const<int>));
69BOOST_MPL_ASSERT_NOT((is_reference_to_non_const<int*>));
70   
71BOOST_MPL_ASSERT_NOT((is_reference_to_volatile<int*&>));
72BOOST_MPL_ASSERT_NOT((is_reference_to_volatile<int* const&>));
73BOOST_MPL_ASSERT((is_reference_to_volatile<int*volatile&>));
74BOOST_MPL_ASSERT((is_reference_to_volatile<int*const volatile&>));
75   
76BOOST_MPL_ASSERT_NOT((is_reference_to_volatile<int const volatile>));
77BOOST_MPL_ASSERT_NOT((is_reference_to_volatile<int>));
78BOOST_MPL_ASSERT_NOT((is_reference_to_volatile<int*>));
79
80namespace tt = boost::python::indirect_traits;
81
82BOOST_MPL_ASSERT_NOT((tt::is_reference_to_class<int>));
83BOOST_MPL_ASSERT_NOT((tt::is_reference_to_class<int&>));
84BOOST_MPL_ASSERT_NOT((tt::is_reference_to_class<int*>));
85   
86
87BOOST_MPL_ASSERT_NOT((tt::is_reference_to_class<pmf>));
88BOOST_MPL_ASSERT_NOT((tt::is_reference_to_class<pmf const&>));
89   
90BOOST_MPL_ASSERT_NOT((tt::is_reference_to_class<X>));
91
92BOOST_MPL_ASSERT((tt::is_reference_to_class<X&>));
93BOOST_MPL_ASSERT((tt::is_reference_to_class<X const&>));
94BOOST_MPL_ASSERT((tt::is_reference_to_class<X volatile&>));
95BOOST_MPL_ASSERT((tt::is_reference_to_class<X const volatile&>));
96   
97BOOST_MPL_ASSERT_NOT((is_pointer_to_class<int>));
98BOOST_MPL_ASSERT_NOT((is_pointer_to_class<int*>));
99BOOST_MPL_ASSERT_NOT((is_pointer_to_class<int&>));
100   
101BOOST_MPL_ASSERT_NOT((is_pointer_to_class<X>));
102BOOST_MPL_ASSERT_NOT((is_pointer_to_class<X&>));
103BOOST_MPL_ASSERT_NOT((is_pointer_to_class<pmf>));
104BOOST_MPL_ASSERT_NOT((is_pointer_to_class<pmf const>));
105BOOST_MPL_ASSERT((is_pointer_to_class<X*>));
106BOOST_MPL_ASSERT((is_pointer_to_class<X const*>));
107BOOST_MPL_ASSERT((is_pointer_to_class<X volatile*>));
108BOOST_MPL_ASSERT((is_pointer_to_class<X const volatile*>));
109
110BOOST_MPL_ASSERT((tt::is_reference_to_member_function_pointer<pmf&>));
111BOOST_MPL_ASSERT((tt::is_reference_to_member_function_pointer<pmf const&>));
112BOOST_MPL_ASSERT((tt::is_reference_to_member_function_pointer<pmf volatile&>));
113BOOST_MPL_ASSERT((tt::is_reference_to_member_function_pointer<pmf const volatile&>));
114BOOST_MPL_ASSERT_NOT((tt::is_reference_to_member_function_pointer<pmf[2]>));
115BOOST_MPL_ASSERT_NOT((tt::is_reference_to_member_function_pointer<pmf(&)[2]>));
116BOOST_MPL_ASSERT_NOT((tt::is_reference_to_member_function_pointer<pmf>));
117   
Note: See TracBrowser for help on using the repository browser.