]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/bind/test/mem_fn_cdecl_test.cpp
1 #include <boost/config.hpp>
11 #if defined(BOOST_MSVC)
12 #pragma warning(disable: 4786) // identifier truncated in debug info
13 #pragma warning(disable: 4710) // function not inlined
14 #pragma warning(disable: 4711) // function selected for automatic inline expansion
15 #pragma warning(disable: 4514) // unreferenced inline removed
19 // mem_fn_cdecl_test.cpp - a test for mem_fn.hpp + __cdecl
21 // Copyright (c) 2005 Peter Dimov
23 // Distributed under the Boost Software License, Version 1.0. (See
24 // accompanying file LICENSE_1_0.txt or copy at
25 // http://www.boost.org/LICENSE_1_0.txt)
28 #define BOOST_MEM_FN_ENABLE_CDECL
30 #include <boost/mem_fn.hpp>
31 #include <boost/shared_ptr.hpp>
33 #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
34 #pragma warning(push, 3)
39 #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
46 mutable unsigned int hash
;
50 int __cdecl
f0() { f1(17); return 0; }
51 int __cdecl
g0() const { g1(17); return 0; }
53 int __cdecl
f1(int a1
) { hash
= (hash
* 17041 + a1
) % 32768; return 0; }
54 int __cdecl
g1(int a1
) const { hash
= (hash
* 17041 + a1
* 2) % 32768; return 0; }
56 int __cdecl
f2(int a1
, int a2
) { f1(a1
); f1(a2
); return 0; }
57 int __cdecl
g2(int a1
, int a2
) const { g1(a1
); g1(a2
); return 0; }
59 int __cdecl
f3(int a1
, int a2
, int a3
) { f2(a1
, a2
); f1(a3
); return 0; }
60 int __cdecl
g3(int a1
, int a2
, int a3
) const { g2(a1
, a2
); g1(a3
); return 0; }
62 int __cdecl
f4(int a1
, int a2
, int a3
, int a4
) { f3(a1
, a2
, a3
); f1(a4
); return 0; }
63 int __cdecl
g4(int a1
, int a2
, int a3
, int a4
) const { g3(a1
, a2
, a3
); g1(a4
); return 0; }
65 int __cdecl
f5(int a1
, int a2
, int a3
, int a4
, int a5
) { f4(a1
, a2
, a3
, a4
); f1(a5
); return 0; }
66 int __cdecl
g5(int a1
, int a2
, int a3
, int a4
, int a5
) const { g4(a1
, a2
, a3
, a4
); g1(a5
); return 0; }
68 int __cdecl
f6(int a1
, int a2
, int a3
, int a4
, int a5
, int a6
) { f5(a1
, a2
, a3
, a4
, a5
); f1(a6
); return 0; }
69 int __cdecl
g6(int a1
, int a2
, int a3
, int a4
, int a5
, int a6
) const { g5(a1
, a2
, a3
, a4
, a5
); g1(a6
); return 0; }
71 int __cdecl
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; }
72 int __cdecl
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; }
74 int __cdecl
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; }
75 int __cdecl
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; }
78 int detect_errors(bool x
)
82 std::cerr
<< "no errors detected.\n";
87 std::cerr
<< "test failed.\n";
101 boost::shared_ptr
<X
> sp(new X
);
113 mem_fn(&X::f1
)(x
, 1);
114 mem_fn(&X::f1
)(&x
, 1);
115 mem_fn(&X::f1
)(sp
, 1);
117 mem_fn(&X::g1
)(x
, 1);
118 mem_fn(&X::g1
)(rcx
, 1);
119 mem_fn(&X::g1
)(&x
, 1);
120 mem_fn(&X::g1
)(pcx
, 1);
121 mem_fn(&X::g1
)(sp
, 1);
123 mem_fn(&X::f2
)(x
, 1, 2);
124 mem_fn(&X::f2
)(&x
, 1, 2);
125 mem_fn(&X::f2
)(sp
, 1, 2);
127 mem_fn(&X::g2
)(x
, 1, 2);
128 mem_fn(&X::g2
)(rcx
, 1, 2);
129 mem_fn(&X::g2
)(&x
, 1, 2);
130 mem_fn(&X::g2
)(pcx
, 1, 2);
131 mem_fn(&X::g2
)(sp
, 1, 2);
133 mem_fn(&X::f3
)(x
, 1, 2, 3);
134 mem_fn(&X::f3
)(&x
, 1, 2, 3);
135 mem_fn(&X::f3
)(sp
, 1, 2, 3);
137 mem_fn(&X::g3
)(x
, 1, 2, 3);
138 mem_fn(&X::g3
)(rcx
, 1, 2, 3);
139 mem_fn(&X::g3
)(&x
, 1, 2, 3);
140 mem_fn(&X::g3
)(pcx
, 1, 2, 3);
141 mem_fn(&X::g3
)(sp
, 1, 2, 3);
143 mem_fn(&X::f4
)(x
, 1, 2, 3, 4);
144 mem_fn(&X::f4
)(&x
, 1, 2, 3, 4);
145 mem_fn(&X::f4
)(sp
, 1, 2, 3, 4);
147 mem_fn(&X::g4
)(x
, 1, 2, 3, 4);
148 mem_fn(&X::g4
)(rcx
, 1, 2, 3, 4);
149 mem_fn(&X::g4
)(&x
, 1, 2, 3, 4);
150 mem_fn(&X::g4
)(pcx
, 1, 2, 3, 4);
151 mem_fn(&X::g4
)(sp
, 1, 2, 3, 4);
153 mem_fn(&X::f5
)(x
, 1, 2, 3, 4, 5);
154 mem_fn(&X::f5
)(&x
, 1, 2, 3, 4, 5);
155 mem_fn(&X::f5
)(sp
, 1, 2, 3, 4, 5);
157 mem_fn(&X::g5
)(x
, 1, 2, 3, 4, 5);
158 mem_fn(&X::g5
)(rcx
, 1, 2, 3, 4, 5);
159 mem_fn(&X::g5
)(&x
, 1, 2, 3, 4, 5);
160 mem_fn(&X::g5
)(pcx
, 1, 2, 3, 4, 5);
161 mem_fn(&X::g5
)(sp
, 1, 2, 3, 4, 5);
163 mem_fn(&X::f6
)(x
, 1, 2, 3, 4, 5, 6);
164 mem_fn(&X::f6
)(&x
, 1, 2, 3, 4, 5, 6);
165 mem_fn(&X::f6
)(sp
, 1, 2, 3, 4, 5, 6);
167 mem_fn(&X::g6
)(x
, 1, 2, 3, 4, 5, 6);
168 mem_fn(&X::g6
)(rcx
, 1, 2, 3, 4, 5, 6);
169 mem_fn(&X::g6
)(&x
, 1, 2, 3, 4, 5, 6);
170 mem_fn(&X::g6
)(pcx
, 1, 2, 3, 4, 5, 6);
171 mem_fn(&X::g6
)(sp
, 1, 2, 3, 4, 5, 6);
173 mem_fn(&X::f7
)(x
, 1, 2, 3, 4, 5, 6, 7);
174 mem_fn(&X::f7
)(&x
, 1, 2, 3, 4, 5, 6, 7);
175 mem_fn(&X::f7
)(sp
, 1, 2, 3, 4, 5, 6, 7);
177 mem_fn(&X::g7
)(x
, 1, 2, 3, 4, 5, 6, 7);
178 mem_fn(&X::g7
)(rcx
, 1, 2, 3, 4, 5, 6, 7);
179 mem_fn(&X::g7
)(&x
, 1, 2, 3, 4, 5, 6, 7);
180 mem_fn(&X::g7
)(pcx
, 1, 2, 3, 4, 5, 6, 7);
181 mem_fn(&X::g7
)(sp
, 1, 2, 3, 4, 5, 6, 7);
183 mem_fn(&X::f8
)(x
, 1, 2, 3, 4, 5, 6, 7, 8);
184 mem_fn(&X::f8
)(&x
, 1, 2, 3, 4, 5, 6, 7, 8);
185 mem_fn(&X::f8
)(sp
, 1, 2, 3, 4, 5, 6, 7, 8);
187 mem_fn(&X::g8
)(x
, 1, 2, 3, 4, 5, 6, 7, 8);
188 mem_fn(&X::g8
)(rcx
, 1, 2, 3, 4, 5, 6, 7, 8);
189 mem_fn(&X::g8
)(&x
, 1, 2, 3, 4, 5, 6, 7, 8);
190 mem_fn(&X::g8
)(pcx
, 1, 2, 3, 4, 5, 6, 7, 8);
191 mem_fn(&X::g8
)(sp
, 1, 2, 3, 4, 5, 6, 7, 8);
193 return detect_errors(x
.hash
== 17610 && sp
->hash
== 2155);