]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/thread/test/functional/invoker/invoker_rvalue_pass.cpp
1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Copyright (C) 2014 Vicente J. Botet Escriba
12 // Distributed under the Boost Software License, Version 1.0. (See accompanying
13 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
15 // <boost/thread/detail/invoker.hpp>
17 #if ! defined BOOST_NO_CXX11_DECLTYPE
18 //#define BOOST_RESULT_OF_USE_DECLTYPE
21 #include <boost/thread/detail/invoker.hpp>
22 #include <boost/detail/lightweight_test.hpp>
35 typedef void result_type
;
36 void operator()(int i
)
41 void mem1() {++count
;}
42 void mem2() const {count
+= 2;}
48 int save_count
= count
;
51 boost::detail::invoker
<void(*)(int), int>(f_void_1
, 2)();
52 BOOST_TEST(count
== save_count
+ 2);
57 void (*fp
)(int) = f_void_1
;
58 boost::detail::invoker
<void(*)(int), int>(fp
, 3)();
59 BOOST_TEST(count
== save_count
+3);
65 #if defined BOOST_THREAD_PROVIDES_INVOKE
66 boost::detail::invoker
<A_void_1
, int>(a0
, 4)();
67 BOOST_TEST(count
== save_count
+4);
70 // boost::detail::invoke<void>(a0, 4);
71 // BOOST_TEST(count == save_count+4);
72 // save_count = count;
74 // member function pointer
76 #if defined BOOST_THREAD_PROVIDES_INVOKE
77 void (A_void_1::*fp
)() = &A_void_1::mem1
;
78 boost::detail::invoker
<void (A_void_1::*)(), A_void_1
>(fp
, A_void_1())();
79 BOOST_TEST(count
== save_count
+1);
83 // boost::detail::invoke<void>(fp, A_void_1());
84 // BOOST_TEST(count == save_count+1);
85 // save_count = count;
86 #if defined BOOST_THREAD_PROVIDES_INVOKE
88 boost::detail::invoker
<void (A_void_1::*)(), A_void_1
*>(fp
, &a
)();
89 BOOST_TEST(count
== save_count
+1);
93 // boost::detail::invoke<int>(fp, &a);
94 // BOOST_TEST(count == save_count+1);
95 // save_count = count;
97 // const member function pointer
99 void (A_void_1::*fp
)() const = &A_void_1::mem2
;
100 boost::detail::invoker
<void (A_void_1::*)() const, A_void_1
>(fp
, A_void_1())();
101 BOOST_TEST(count
== save_count
+2);
104 boost::detail::invoker
<void (A_void_1::*)() const, A_void_1
*>(fp
, &a
)();
105 BOOST_TEST(count
== save_count
+2);
119 A_int_1() : data_(5) {}
120 int operator()(int i
)
125 int mem1() {return 3;}
126 int mem2() const {return 4;}
135 BOOST_TEST((boost::detail::invoker
<int (*)(int), int>(f_int_1
, 2)() == 3));
139 int (*fp
)(int) = f_int_1
;
140 BOOST_TEST((boost::detail::invoker
<int (*)(int), int>(fp
, 3)() == 4));
144 #if defined BOOST_THREAD_PROVIDES_INVOKE
145 BOOST_TEST((boost::detail::invoker
<A_int_1
, int>(A_int_1(), 4)() == 3));
146 // BOOST_TEST(boost::detail::invoke<int>(A_int_1(), 4) == 3);
149 // member function pointer
151 #if defined BOOST_THREAD_PROVIDES_INVOKE
152 BOOST_TEST((boost::detail::invoker
<int (A_int_1::*)(),A_int_1
>(&A_int_1::mem1
, A_int_1())() == 3));
153 // BOOST_TEST(boost::detail::invoke<int>(&A_int_1::mem1, A_int_1()) == 3);
157 BOOST_TEST((boost::detail::invoker
<int (A_int_1::*)(), A_int_1
*>(&A_int_1::mem1
, &a
)() == 3));
159 // const member function pointer
161 BOOST_TEST((boost::detail::invoker
<int (A_int_1::*)() const, A_int_1
>(&A_int_1::mem2
, A_int_1())() == 4));
163 BOOST_TEST((boost::detail::invoker
<int (A_int_1::*)() const, A_int_1
*>(&A_int_1::mem2
, &a
)() == 4));
165 // member data pointer
167 #if defined BOOST_THREAD_PROVIDES_INVOKE
168 // BOOST_TEST((boost::detail::invoker<int A_int_1::*>(&A_int_1::data_, A_int_1())() == 5));
169 //// BOOST_TEST(boost::detail::invoke<int>(&A_int_1::data_, A_int_1()) == 5);
171 // BOOST_TEST((boost::detail::invoker<int A_int_1::*>(&A_int_1::data_, a)() == 5));
172 // boost::detail::invoker<int A_int_1::*>(&A_int_1::data_, a)() = 6;
173 // BOOST_TEST((boost::detail::invoker<int A_int_1::*>(&A_int_1::data_, a)() == 6));
174 // BOOST_TEST((boost::detail::invoker<int A_int_1::*>(&A_int_1::data_, &a)() == 6));
175 // boost::detail::invoker<int A_int_1::*>(&A_int_1::data_, &a)() = 7;
176 // BOOST_TEST((boost::detail::invoker<int A_int_1::*>(&A_int_1::data_, &a)() == 7));
181 // 2 arg, return void
183 void f_void_2(int i
, int j
)
190 void operator()(int i
, int j
)
195 void mem1(int i
) {count
+= i
;}
196 void mem2(int i
) const {count
+= i
;}
202 int save_count
= count
;
205 boost::detail::invoke(f_void_2
, 2, 3);
206 BOOST_TEST(count
== save_count
+5);
209 // member function pointer
211 #if defined BOOST_THREAD_PROVIDES_INVOKE
212 boost::detail::invoke(&A_void_2::mem1
, A_void_2(), 3);
213 BOOST_TEST(count
== save_count
+3);
216 boost::detail::invoke
<void>(&A_void_2::mem1
, A_void_2(), 3);
217 BOOST_TEST(count
== save_count
+3);
229 return boost::report_errors();