summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/python/test/indirect_traits_test.cpp
blob: da4cc24569153cf8f2cdfec36ed7d5524c7f8f43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// Copyright David Abrahams 2004. Distributed under the Boost
// Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//#include <stdio.h>
#define BOOST_ENABLE_ASSERT_HANDLER
#include <boost/assert.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/python/detail/indirect_traits.hpp>
#include <boost/mpl/assert.hpp>

//#define print(expr) printf("%s ==> %s\n", #expr, expr)

// not all the compilers can handle an incomplete class type here.
struct X {};

using namespace boost::python::indirect_traits;

typedef void (X::*pmf)();

BOOST_MPL_ASSERT((is_reference_to_function<int (&)()>));
BOOST_MPL_ASSERT_NOT((is_reference_to_function<int (*)()>));
BOOST_MPL_ASSERT_NOT((is_reference_to_function<int&>));
BOOST_MPL_ASSERT_NOT((is_reference_to_function<pmf>));
    
BOOST_MPL_ASSERT_NOT((is_pointer_to_function<int (&)()>));
BOOST_MPL_ASSERT((is_pointer_to_function<int (*)()>));
BOOST_MPL_ASSERT_NOT((is_pointer_to_function<int (*&)()>));
BOOST_MPL_ASSERT_NOT((is_pointer_to_function<int (*const&)()>));
BOOST_MPL_ASSERT_NOT((is_pointer_to_function<pmf>));
    
BOOST_MPL_ASSERT_NOT((is_reference_to_function_pointer<int (&)()>));
BOOST_MPL_ASSERT_NOT((is_reference_to_function_pointer<int (*)()>));
BOOST_MPL_ASSERT_NOT((is_reference_to_function_pointer<int&>));
BOOST_MPL_ASSERT((is_reference_to_function_pointer<int (*&)()>));
BOOST_MPL_ASSERT((is_reference_to_function_pointer<int (*const&)()>));
BOOST_MPL_ASSERT_NOT((is_reference_to_function_pointer<pmf>));

BOOST_MPL_ASSERT((is_reference_to_pointer<int*&>));
BOOST_MPL_ASSERT((is_reference_to_pointer<int* const&>));
BOOST_MPL_ASSERT((is_reference_to_pointer<int*volatile&>));
BOOST_MPL_ASSERT((is_reference_to_pointer<int*const volatile&>));
BOOST_MPL_ASSERT((is_reference_to_pointer<int const*&>));
BOOST_MPL_ASSERT((is_reference_to_pointer<int const* const&>));
BOOST_MPL_ASSERT((is_reference_to_pointer<int const*volatile&>));
BOOST_MPL_ASSERT((is_reference_to_pointer<int const*const volatile&>));
BOOST_MPL_ASSERT_NOT((is_reference_to_pointer<pmf>));

BOOST_MPL_ASSERT_NOT((is_reference_to_pointer<int const volatile>));
BOOST_MPL_ASSERT_NOT((is_reference_to_pointer<int>));
BOOST_MPL_ASSERT_NOT((is_reference_to_pointer<int*>));

BOOST_MPL_ASSERT_NOT((is_reference_to_const<int*&>));
BOOST_MPL_ASSERT((is_reference_to_const<int* const&>));
BOOST_MPL_ASSERT_NOT((is_reference_to_const<int*volatile&>));
BOOST_MPL_ASSERT((is_reference_to_const<int*const volatile&>));
    
BOOST_MPL_ASSERT_NOT((is_reference_to_const<int const volatile>));
BOOST_MPL_ASSERT_NOT((is_reference_to_const<int>));
BOOST_MPL_ASSERT_NOT((is_reference_to_const<int*>));

BOOST_MPL_ASSERT((is_reference_to_non_const<int*&>));
BOOST_MPL_ASSERT_NOT((is_reference_to_non_const<int* const&>));
BOOST_MPL_ASSERT((is_reference_to_non_const<int*volatile&>));
BOOST_MPL_ASSERT_NOT((is_reference_to_non_const<int*const volatile&>));
    
BOOST_MPL_ASSERT_NOT((is_reference_to_non_const<int const volatile>));
BOOST_MPL_ASSERT_NOT((is_reference_to_non_const<int>));
BOOST_MPL_ASSERT_NOT((is_reference_to_non_const<int*>));
    
BOOST_MPL_ASSERT_NOT((is_reference_to_volatile<int*&>));
BOOST_MPL_ASSERT_NOT((is_reference_to_volatile<int* const&>));
BOOST_MPL_ASSERT((is_reference_to_volatile<int*volatile&>));
BOOST_MPL_ASSERT((is_reference_to_volatile<int*const volatile&>));
    
BOOST_MPL_ASSERT_NOT((is_reference_to_volatile<int const volatile>));
BOOST_MPL_ASSERT_NOT((is_reference_to_volatile<int>));
BOOST_MPL_ASSERT_NOT((is_reference_to_volatile<int*>));

namespace tt = boost::python::indirect_traits;

BOOST_MPL_ASSERT_NOT((tt::is_reference_to_class<int>));
BOOST_MPL_ASSERT_NOT((tt::is_reference_to_class<int&>));
BOOST_MPL_ASSERT_NOT((tt::is_reference_to_class<int*>));
    

BOOST_MPL_ASSERT_NOT((tt::is_reference_to_class<pmf>));
BOOST_MPL_ASSERT_NOT((tt::is_reference_to_class<pmf const&>));
    
BOOST_MPL_ASSERT_NOT((tt::is_reference_to_class<X>));

BOOST_MPL_ASSERT((tt::is_reference_to_class<X&>));
BOOST_MPL_ASSERT((tt::is_reference_to_class<X const&>));
BOOST_MPL_ASSERT((tt::is_reference_to_class<X volatile&>));
BOOST_MPL_ASSERT((tt::is_reference_to_class<X const volatile&>));
    
BOOST_MPL_ASSERT_NOT((is_pointer_to_class<int>));
BOOST_MPL_ASSERT_NOT((is_pointer_to_class<int*>));
BOOST_MPL_ASSERT_NOT((is_pointer_to_class<int&>));
    
BOOST_MPL_ASSERT_NOT((is_pointer_to_class<X>));
BOOST_MPL_ASSERT_NOT((is_pointer_to_class<X&>));
BOOST_MPL_ASSERT_NOT((is_pointer_to_class<pmf>));
BOOST_MPL_ASSERT_NOT((is_pointer_to_class<pmf const>));
BOOST_MPL_ASSERT((is_pointer_to_class<X*>));
BOOST_MPL_ASSERT((is_pointer_to_class<X const*>));
BOOST_MPL_ASSERT((is_pointer_to_class<X volatile*>));
BOOST_MPL_ASSERT((is_pointer_to_class<X const volatile*>));

BOOST_MPL_ASSERT((tt::is_reference_to_member_function_pointer<pmf&>));
BOOST_MPL_ASSERT((tt::is_reference_to_member_function_pointer<pmf const&>));
BOOST_MPL_ASSERT((tt::is_reference_to_member_function_pointer<pmf volatile&>));
BOOST_MPL_ASSERT((tt::is_reference_to_member_function_pointer<pmf const volatile&>));
BOOST_MPL_ASSERT_NOT((tt::is_reference_to_member_function_pointer<pmf[2]>));
BOOST_MPL_ASSERT_NOT((tt::is_reference_to_member_function_pointer<pmf(&)[2]>));
BOOST_MPL_ASSERT_NOT((tt::is_reference_to_member_function_pointer<pmf>));