Skip to content

Commit 331209d

Browse files
committed
Fix link in news
Improve assertions in indirect_traits_test by making them compile-time and using MPL assert primitives [SVN r29782]
1 parent 9116cf3 commit 331209d

3 files changed

Lines changed: 89 additions & 81 deletions

File tree

doc/news.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ <h2 align="center">News/Change Log</h2>
4141
<dd>
4242
<ul>
4343
<li>Updated to use the Boost Software License.</li>
44-
<li>A new, <a href="libs/python/doc/tutorial/doc/html/python/exposing.html#python.class_virtual_functions">better method of wrapping classes with virtual functions</a> has been implemented.</li>
44+
<li>A new, <a href="tutorial/doc/html/python/exposing.html#python.class_virtual_functions">better method of wrapping classes with virtual functions</a> has been implemented.</li>
4545
<li>Support for upcoming GCC symbol export control features have been folded in, thanks to Niall Douglas.</li>
4646
<li>Improved support for <code>std::auto_ptr</code>-like types.</li>
4747
<li>The Visual C++ bug that makes top-level <i>cv-qualification</i> of function parameter types part of the function type has been worked around.</li>

test/Jamfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ bpl-test crossmod_exception
176176

177177
# --- unit tests of library components ---
178178

179-
[ run indirect_traits_test.cpp ]
179+
[ compile indirect_traits_test.cpp ]
180180
[ run destroy_test.cpp ]
181181
[ run pointer_type_id_test.cpp <template>py-unit-test ]
182182
[ run bases.cpp <template>py-unit-test ]

test/indirect_traits_test.cpp

Lines changed: 87 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -3,106 +3,114 @@
33
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
44
//#include <stdio.h>
55
#include <cassert>
6+
#include <boost/type_traits/is_member_function_pointer.hpp>
7+
#include <boost/mpl/assert.hpp>
68
#include <boost/python/detail/indirect_traits.hpp>
9+
#include <boost/mpl/assert.hpp>
710

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

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

13-
int main()
14-
{
15-
using namespace boost::python::indirect_traits;
16+
using namespace boost::python::indirect_traits;
1617

17-
typedef void (X::*pmf)();
18+
typedef void (X::*pmf)();
1819

19-
assert(is_reference_to_function<int (&)()>::value);
20-
assert(!is_reference_to_function<int (*)()>::value);
21-
assert(!is_reference_to_function<int&>::value);
22-
assert(!is_reference_to_function<pmf>::value);
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>));
2324

24-
assert(!is_pointer_to_function<int (&)()>::value);
25-
assert(is_pointer_to_function<int (*)()>::value);
26-
assert(!is_pointer_to_function<int (*&)()>::value);
27-
assert(!is_pointer_to_function<int (*const&)()>::value);
28-
assert(!is_pointer_to_function<pmf>::value);
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>));
2930

30-
assert(!is_reference_to_function_pointer<int (&)()>::value);
31-
assert(!is_reference_to_function_pointer<int (*)()>::value);
32-
assert(!is_reference_to_function_pointer<int&>::value);
33-
assert(is_reference_to_function_pointer<int (*&)()>::value);
34-
assert(is_reference_to_function_pointer<int (*const&)()>::value);
35-
assert(!is_reference_to_function_pointer<pmf>::value);
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>));
3637

37-
assert(is_reference_to_pointer<int*&>::value);
38-
assert(is_reference_to_pointer<int* const&>::value);
39-
assert(is_reference_to_pointer<int*volatile&>::value);
40-
assert(is_reference_to_pointer<int*const volatile&>::value);
41-
assert(is_reference_to_pointer<int const*&>::value);
42-
assert(is_reference_to_pointer<int const* const&>::value);
43-
assert(is_reference_to_pointer<int const*volatile&>::value);
44-
assert(is_reference_to_pointer<int const*const volatile&>::value);
45-
assert(!is_reference_to_pointer<pmf>::value);
46-
47-
assert(!is_reference_to_pointer<int const volatile>::value);
48-
assert(!is_reference_to_pointer<int>::value);
49-
assert(!is_reference_to_pointer<int*>::value);
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*>));
5051

51-
assert(!is_reference_to_const<int*&>::value);
52-
assert(is_reference_to_const<int* const&>::value);
53-
assert(!is_reference_to_const<int*volatile&>::value);
54-
assert(is_reference_to_const<int*const volatile&>::value);
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&>));
5556

56-
assert(!is_reference_to_const<int const volatile>::value);
57-
assert(!is_reference_to_const<int>::value);
58-
assert(!is_reference_to_const<int*>::value);
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*>));
5960

60-
assert(is_reference_to_non_const<int*&>::value);
61-
assert(!is_reference_to_non_const<int* const&>::value);
62-
assert(is_reference_to_non_const<int*volatile&>::value);
63-
assert(!is_reference_to_non_const<int*const volatile&>::value);
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*>));
6469

65-
assert(!is_reference_to_non_const<int const volatile>::value);
66-
assert(!is_reference_to_non_const<int>::value);
67-
assert(!is_reference_to_non_const<int*>::value);
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&>));
6874

69-
assert(!is_reference_to_volatile<int*&>::value);
70-
assert(!is_reference_to_volatile<int* const&>::value);
71-
assert(is_reference_to_volatile<int*volatile&>::value);
72-
assert(is_reference_to_volatile<int*const volatile&>::value);
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*>));
7384

74-
assert(!is_reference_to_volatile<int const volatile>::value);
75-
assert(!is_reference_to_volatile<int>::value);
76-
assert(!is_reference_to_volatile<int*>::value);
7785

78-
assert(!is_reference_to_class<int>::value);
79-
assert(!is_reference_to_class<int&>::value);
80-
assert(!is_reference_to_class<int*>::value);
86+
BOOST_MPL_ASSERT_NOT((tt::is_reference_to_class<pmf>));
87+
BOOST_MPL_ASSERT_NOT((tt::is_reference_to_class<pmf const&>));
8188

82-
assert(!is_reference_to_class<X>::value);
83-
assert(is_reference_to_class<X&>::value);
84-
assert(is_reference_to_class<X const&>::value);
85-
assert(is_reference_to_class<X volatile&>::value);
86-
assert(is_reference_to_class<X const volatile&>::value);
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&>));
8795

88-
assert(!is_pointer_to_class<int>::value);
89-
assert(!is_pointer_to_class<int*>::value);
90-
assert(!is_pointer_to_class<int&>::value);
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&>));
9199

92-
assert(!is_pointer_to_class<X>::value);
93-
assert(!is_pointer_to_class<X&>::value);
94-
assert(is_pointer_to_class<X*>::value);
95-
assert(is_pointer_to_class<X const*>::value);
96-
assert(is_pointer_to_class<X volatile*>::value);
97-
assert(is_pointer_to_class<X const volatile*>::value);
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*>));
98108

99-
assert(is_reference_to_member_function_pointer<pmf&>::value);
100-
assert(is_reference_to_member_function_pointer<pmf const&>::value);
101-
assert(is_reference_to_member_function_pointer<pmf volatile&>::value);
102-
assert(is_reference_to_member_function_pointer<pmf const volatile&>::value);
103-
assert(!is_reference_to_member_function_pointer<pmf[2]>::value);
104-
assert(!is_reference_to_member_function_pointer<pmf(&)[2]>::value);
105-
assert(!is_reference_to_member_function_pointer<pmf>::value);
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>));
106116

107-
return 0;
108-
}

0 commit comments

Comments
 (0)