]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/callable_traits/test/is_invocable.cpp
2 Copyright Barrett Adair 2016-2017
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt)
10 #include <boost/callable_traits/is_invocable.hpp>
13 #ifdef BOOST_CLBL_TRTS_GCC_OLDER_THAN_4_9_2
14 //gcc >= 4.8 doesn't like the invoke_case pattern used here
23 template<bool Expect
, typename
... Args
>
25 template<typename Callable
>
26 void operator()(tag
<Callable
>) const {
27 CT_ASSERT((Expect
== boost::callable_traits::is_invocable
<Callable
, Args
...>()));
31 template<typename Callable
, typename
... InvokeCases
>
33 using ignored
= int[];
34 ignored x
{(InvokeCases
{}(tag
<Callable
>{}),0)..., 0};
42 run_tests
<void(foo::*)()
43 ,invoke_case
<true, foo
>
44 ,invoke_case
<true, foo
*>
45 ,invoke_case
<true, foo
&>
46 ,invoke_case
<true, foo
&&>
47 ,invoke_case
<true, std::reference_wrapper
<foo
>>
48 ,invoke_case
<false, foo
const>
49 ,invoke_case
<false, foo
const*>
50 ,invoke_case
<false, foo
const&>
51 ,invoke_case
<false, foo
const&&>
52 ,invoke_case
<false, std::reference_wrapper
<foo
const>>
53 ,invoke_case
<false, foo
, int>
54 ,invoke_case
<false, foo
*, int>
55 ,invoke_case
<false, foo
&, int>
56 ,invoke_case
<false, foo
&&, int>
57 ,invoke_case
<false, std::reference_wrapper
<foo
>, int>
60 run_tests
<void(foo::*)() LREF
61 ,invoke_case
<false, foo
>
62 ,invoke_case
<true, foo
*>
63 ,invoke_case
<true, foo
&>
64 ,invoke_case
<false, foo
&&>
65 ,invoke_case
<true, std::reference_wrapper
<foo
>>
66 ,invoke_case
<false, foo
const>
67 ,invoke_case
<false, foo
const*>
68 ,invoke_case
<false, foo
const&>
69 ,invoke_case
<false, foo
const&&>
70 ,invoke_case
<false, std::reference_wrapper
<foo
const>>
71 ,invoke_case
<false, foo
, int>
72 ,invoke_case
<false, foo
*, int>
73 ,invoke_case
<false, foo
&, int>
74 ,invoke_case
<false, foo
&&, int>
75 ,invoke_case
<false, std::reference_wrapper
<foo
>, int>
78 run_tests
<void(foo::*)() RREF
79 ,invoke_case
<true, foo
>
80 ,invoke_case
<false, foo
*>
81 ,invoke_case
<false, foo
&>
82 ,invoke_case
<true, foo
&&>
83 ,invoke_case
<false, std::reference_wrapper
<foo
>>
84 ,invoke_case
<false, foo
const>
85 ,invoke_case
<false, foo
const*>
86 ,invoke_case
<false, foo
const&>
87 ,invoke_case
<false, foo
const&&>
88 ,invoke_case
<false, std::reference_wrapper
<foo
const>>
89 ,invoke_case
<false, foo
, int>
90 ,invoke_case
<false, foo
*, int>
91 ,invoke_case
<false, foo
&, int>
92 ,invoke_case
<false, foo
&&, int>
93 ,invoke_case
<false, std::reference_wrapper
<foo
>, int>
96 run_tests
<void(foo::*)() const
97 ,invoke_case
<true, foo
>
98 ,invoke_case
<true, foo
*>
99 ,invoke_case
<true, foo
&>
100 ,invoke_case
<true, foo
&&>
101 ,invoke_case
<true, std::reference_wrapper
<foo
>>
102 ,invoke_case
<true, foo
const>
103 ,invoke_case
<true, foo
const*>
104 ,invoke_case
<true, foo
const&>
105 ,invoke_case
<true, foo
const&&>
106 ,invoke_case
<true, std::reference_wrapper
<foo
const>>
107 ,invoke_case
<false, foo
, int>
108 ,invoke_case
<false, foo
*, int>
109 ,invoke_case
<false, foo
&, int>
110 ,invoke_case
<false, foo
&&, int>
111 ,invoke_case
<false, std::reference_wrapper
<foo
>, int>
114 // MSVC doesn't handle cv + ref qualifiers in expression sfinae correctly
115 #ifndef BOOST_CLBL_TRTS_MSVC
117 run_tests
<void(foo::*)() const LREF
118 ,invoke_case
<false, foo
>
119 ,invoke_case
<true, foo
*>
120 ,invoke_case
<true, foo
&>
121 ,invoke_case
<false, foo
&&>
122 ,invoke_case
<true, std::reference_wrapper
<foo
>>
123 ,invoke_case
<false, foo
const>
124 ,invoke_case
<true, foo
const*>
125 ,invoke_case
<true, foo
const&>
126 ,invoke_case
<false, foo
const&&>
127 ,invoke_case
<true, std::reference_wrapper
<foo
const>>
128 ,invoke_case
<false, foo
, int>
129 ,invoke_case
<false, foo
*, int>
130 ,invoke_case
<false, foo
&, int>
131 ,invoke_case
<false, foo
&&, int>
132 ,invoke_case
<false, std::reference_wrapper
<foo
>, int>
135 run_tests
<void(foo::*)() const RREF
136 ,invoke_case
<true, foo
>
137 ,invoke_case
<false, foo
*>
138 ,invoke_case
<false, foo
&>
139 ,invoke_case
<true, foo
&&>
140 ,invoke_case
<false, std::reference_wrapper
<foo
>>
141 ,invoke_case
<true, foo
const>
142 ,invoke_case
<false, foo
const*>
143 ,invoke_case
<false, foo
const&>
144 ,invoke_case
<true, foo
const&&>
145 ,invoke_case
<false, std::reference_wrapper
<foo
const>>
146 ,invoke_case
<false, foo
, int>
147 ,invoke_case
<false, foo
*, int>
148 ,invoke_case
<false, foo
&, int>
149 ,invoke_case
<false, foo
&&, int>
150 ,invoke_case
<false, std::reference_wrapper
<foo
>, int>
153 #endif // #ifndef BOOST_CLBL_TRTS_MSVC
156 ,invoke_case
<false, foo
>
157 ,invoke_case
<false, foo
*>
158 ,invoke_case
<false, foo
&>
159 ,invoke_case
<false, foo
&&>
160 ,invoke_case
<false, std::reference_wrapper
<foo
>>
161 ,invoke_case
<false, foo
const>
162 ,invoke_case
<false, foo
const*>
163 ,invoke_case
<false, foo
const&>
164 ,invoke_case
<false, foo
const&&>
165 ,invoke_case
<false, std::reference_wrapper
<foo
const>>
166 ,invoke_case
<false, foo
, int>
167 ,invoke_case
<false, foo
*, int>
168 ,invoke_case
<false, foo
&, int>
169 ,invoke_case
<false, foo
&&, int>
170 ,invoke_case
<false, std::reference_wrapper
<foo
>, int>
175 run_tests
<decltype(f
)
176 ,invoke_case
<true, int>
177 ,invoke_case
<true, char>
178 ,invoke_case
<false, void*>
181 run_tests
<decltype(f
)&
182 ,invoke_case
<true, int>
183 ,invoke_case
<true, char>
184 ,invoke_case
<false, void*>
187 run_tests
<decltype(std::ref(f
))
188 ,invoke_case
<true, int>
189 ,invoke_case
<true, char>
190 ,invoke_case
<false, void*>
193 run_tests
<decltype(std::ref(f
))&
194 ,invoke_case
<true, int>
195 ,invoke_case
<true, char>
196 ,invoke_case
<false, void*>
199 run_tests
<decltype(std::ref(f
))&&
200 ,invoke_case
<true, int>
201 ,invoke_case
<true, char>
202 ,invoke_case
<false, void*>
205 run_tests
<decltype(std::ref(f
)) const &
206 ,invoke_case
<true, int>
207 ,invoke_case
<true, char>
208 ,invoke_case
<false, void*>
211 run_tests
<decltype(std::ref(f
)) const &&
212 ,invoke_case
<true, int>
213 ,invoke_case
<true, char>
214 ,invoke_case
<false, void*>
217 run_tests
<decltype(f
)&&
218 ,invoke_case
<true, int>
219 ,invoke_case
<true, char>
220 ,invoke_case
<false, void*>
223 run_tests
<decltype(f
) const &
224 ,invoke_case
<true, int>
225 ,invoke_case
<true, char>
226 ,invoke_case
<false, void*>
229 run_tests
<decltype(f
) const &&
230 ,invoke_case
<true, int>
231 ,invoke_case
<true, char>
232 ,invoke_case
<false, void*>
236 ,invoke_case
<true, int>
237 ,invoke_case
<true, char>
238 ,invoke_case
<false, void*>
241 run_tests
<void(int) const
242 ,invoke_case
<false, int>
243 ,invoke_case
<false, char>
244 ,invoke_case
<false, void*>
248 ,invoke_case
<false, int>
249 ,invoke_case
<false, char>
250 ,invoke_case
<false, void*>
254 ,invoke_case
<false, foo
>
255 ,invoke_case
<false, foo
*>
256 ,invoke_case
<false, foo
&>
257 ,invoke_case
<false, foo
&&>
258 ,invoke_case
<false, std::reference_wrapper
<foo
>>
259 ,invoke_case
<false, foo
const>
260 ,invoke_case
<false, foo
const*>
261 ,invoke_case
<false, foo
const&>
262 ,invoke_case
<false, foo
const&&>
263 ,invoke_case
<false, std::reference_wrapper
<foo
const>>
264 ,invoke_case
<false, foo
, int>
265 ,invoke_case
<false, foo
*, int>
266 ,invoke_case
<false, foo
&, int>
267 ,invoke_case
<false, foo
&&, int>
268 ,invoke_case
<false, std::reference_wrapper
<foo
>, int>
273 ,invoke_case
<false, foo
>
274 ,invoke_case
<false, foo
*>
275 ,invoke_case
<false, foo
&>
276 ,invoke_case
<false, foo
&&>
277 ,invoke_case
<false, std::reference_wrapper
<foo
>>
278 ,invoke_case
<false, foo
const>
279 ,invoke_case
<false, foo
const*>
280 ,invoke_case
<false, foo
const&>
281 ,invoke_case
<false, foo
const&&>
282 ,invoke_case
<false, std::reference_wrapper
<foo
const>>
283 ,invoke_case
<false, foo
, int>
284 ,invoke_case
<false, foo
*, int>
285 ,invoke_case
<false, foo
&, int>
286 ,invoke_case
<false, foo
&&, int>
287 ,invoke_case
<false, std::reference_wrapper
<foo
>, int>
291 ,invoke_case
<false, foo
>
292 ,invoke_case
<false, foo
*>
293 ,invoke_case
<false, foo
&>
294 ,invoke_case
<false, foo
&&>
295 ,invoke_case
<false, std::reference_wrapper
<foo
>>
296 ,invoke_case
<false, foo
const>
297 ,invoke_case
<false, foo
const*>
298 ,invoke_case
<false, foo
const&>
299 ,invoke_case
<false, foo
const&&>
300 ,invoke_case
<false, std::reference_wrapper
<foo
const>>
301 ,invoke_case
<false, foo
, int>
302 ,invoke_case
<false, foo
*, int>
303 ,invoke_case
<false, foo
&, int>
304 ,invoke_case
<false, foo
&&, int>
305 ,invoke_case
<false, std::reference_wrapper
<foo
>, int>
309 #endif //#ifdef BOOST_CLBL_TRTS_GCC_OLDER_THAN_4_9_2