]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/bind/test/bind_void_mf_test.cpp
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / boost / libs / bind / test / bind_void_mf_test.cpp
CommitLineData
7c673cae
FG
1#include <boost/config.hpp>
2
3#if defined(BOOST_MSVC)
4#pragma warning(disable: 4786) // identifier truncated in debug info
5#pragma warning(disable: 4710) // function not inlined
6#pragma warning(disable: 4711) // function selected for automatic inline expansion
7#pragma warning(disable: 4514) // unreferenced inline removed
8#endif
9
10//
11// bind_void_mf_test.cpp - test for bind<void> with member functions
12//
13// Copyright (c) 2008 Peter Dimov
14// Copyright (c) 2014 Agustin Berge
15//
16// Distributed under the Boost Software License, Version 1.0. (See
17// accompanying file LICENSE_1_0.txt or copy at
18// http://www.boost.org/LICENSE_1_0.txt)
19//
20
f67539c2 21#include <boost/bind/bind.hpp>
7c673cae 22#include <boost/ref.hpp>
f67539c2 23#include <boost/core/lightweight_test.hpp>
7c673cae
FG
24
25//
26
27long global_result;
28
29//
30
31struct X
32{
33 mutable unsigned int hash;
34
35 X(): hash(0) {}
36
37 int f0() { f1(17); return 0; }
38 int g0() const { g1(17); return 0; }
39 void h0() { h1(17); }
40
41 int f1(int a1) { hash = (hash * 17041 + a1) % 32768; return 0; }
42 int g1(int a1) const { hash = (hash * 17041 + a1 * 2) % 32768; return 0; }
43 void h1(int a1) { hash = (hash * 17041 + a1 * 2) % 32768; }
44
45 int f2(int a1, int a2) { f1(a1); f1(a2); return 0; }
46 int g2(int a1, int a2) const { g1(a1); g1(a2); return 0; }
47 void h2(int a1, int a2) { h1(a1); h1(a2); }
48
49 int f3(int a1, int a2, int a3) { f2(a1, a2); f1(a3); return 0; }
50 int g3(int a1, int a2, int a3) const { g2(a1, a2); g1(a3); return 0; }
51 void h3(int a1, int a2, int a3) { h2(a1, a2); h1(a3); }
52
53 int f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); return 0; }
54 int g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); return 0; }
55 void h4(int a1, int a2, int a3, int a4) { h3(a1, a2, a3); h1(a4); }
56
57 int f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); return 0; }
58 int g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); return 0; }
59 void h5(int a1, int a2, int a3, int a4, int a5) { h4(a1, a2, a3, a4); h1(a5); }
60
61 int f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); return 0; }
62 int g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); return 0; }
63 void h6(int a1, int a2, int a3, int a4, int a5, int a6) { h5(a1, a2, a3, a4, a5); h1(a6); }
64
65 int f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); return 0; }
66 int g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); return 0; }
67 void h7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { h6(a1, a2, a3, a4, a5, a6); h1(a7); }
68
69 int f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); return 0; }
70 int g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; }
71 void h8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { h7(a1, a2, a3, a4, a5, a6, a7); h1(a8); }
72};
73
74void member_function_test()
75{
76 using namespace boost;
77
78 X x;
79
80 // 0
81
82 bind<void>(&X::f0, &x)();
83 bind<void>(&X::f0, ref(x))();
84
85 bind<void>(&X::g0, &x)();
86 bind<void>(&X::g0, x)();
87 bind<void>(&X::g0, ref(x))();
88
89 bind<void>(&X::h0, x)();
90
91 // 1
92
93 bind<void>(&X::f1, &x, 1)();
94 bind<void>(&X::f1, ref(x), 1)();
95
96 bind<void>(&X::g1, &x, 1)();
97 bind<void>(&X::g1, x, 1)();
98 bind<void>(&X::g1, ref(x), 1)();
99
100 bind<void>(&X::h1, x, 1)();
101
102 // 2
103
104 bind<void>(&X::f2, &x, 1, 2)();
105 bind<void>(&X::f2, ref(x), 1, 2)();
106
107 bind<void>(&X::g2, &x, 1, 2)();
108 bind<void>(&X::g2, x, 1, 2)();
109 bind<void>(&X::g2, ref(x), 1, 2)();
110
111 bind<void>(&X::h2, x, 1, 2)();
112
113 // 3
114
115 bind<void>(&X::f3, &x, 1, 2, 3)();
116 bind<void>(&X::f3, ref(x), 1, 2, 3)();
117
118 bind<void>(&X::g3, &x, 1, 2, 3)();
119 bind<void>(&X::g3, x, 1, 2, 3)();
120 bind<void>(&X::g3, ref(x), 1, 2, 3)();
121
122 bind<void>(&X::h3, x, 1, 2, 3)();
123
124 // 4
125
126 bind<void>(&X::f4, &x, 1, 2, 3, 4)();
127 bind<void>(&X::f4, ref(x), 1, 2, 3, 4)();
128
129 bind<void>(&X::g4, &x, 1, 2, 3, 4)();
130 bind<void>(&X::g4, x, 1, 2, 3, 4)();
131 bind<void>(&X::g4, ref(x), 1, 2, 3, 4)();
132
133 bind<void>(&X::h4, x, 1, 2, 3, 4)();
134
135 // 5
136
137 bind<void>(&X::f5, &x, 1, 2, 3, 4, 5)();
138 bind<void>(&X::f5, ref(x), 1, 2, 3, 4, 5)();
139
140 bind<void>(&X::g5, &x, 1, 2, 3, 4, 5)();
141 bind<void>(&X::g5, x, 1, 2, 3, 4, 5)();
142 bind<void>(&X::g5, ref(x), 1, 2, 3, 4, 5)();
143
144 bind<void>(&X::h5, x, 1, 2, 3, 4, 5)();
145
146 // 6
147
148 bind<void>(&X::f6, &x, 1, 2, 3, 4, 5, 6)();
149 bind<void>(&X::f6, ref(x), 1, 2, 3, 4, 5, 6)();
150
151 bind<void>(&X::g6, &x, 1, 2, 3, 4, 5, 6)();
152 bind<void>(&X::g6, x, 1, 2, 3, 4, 5, 6)();
153 bind<void>(&X::g6, ref(x), 1, 2, 3, 4, 5, 6)();
154
155 bind<void>(&X::h6, x, 1, 2, 3, 4, 5, 6)();
156
157 // 7
158
159 bind<void>(&X::f7, &x, 1, 2, 3, 4, 5, 6, 7)();
160 bind<void>(&X::f7, ref(x), 1, 2, 3, 4, 5, 6, 7)();
161
162 bind<void>(&X::g7, &x, 1, 2, 3, 4, 5, 6, 7)();
163 bind<void>(&X::g7, x, 1, 2, 3, 4, 5, 6, 7)();
164 bind<void>(&X::g7, ref(x), 1, 2, 3, 4, 5, 6, 7)();
165
166 bind<void>(&X::h7, x, 1, 2, 3, 4, 5, 6, 7)();
167
168 // 8
169
170 bind<void>(&X::f8, &x, 1, 2, 3, 4, 5, 6, 7, 8)();
171 bind<void>(&X::f8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8)();
172
173 bind<void>(&X::g8, &x, 1, 2, 3, 4, 5, 6, 7, 8)();
174 bind<void>(&X::g8, x, 1, 2, 3, 4, 5, 6, 7, 8)();
175 bind<void>(&X::g8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8)();
176
177 bind<void>(&X::h8, x, 1, 2, 3, 4, 5, 6, 7, 8)();
178
179 BOOST_TEST( x.hash == 23558 );
180}
181
182int main()
183{
184 member_function_test();
185
186 return boost::report_errors();
187}