]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/20_util/result_of/sfinae_friendly_1.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 20_util / result_of / sfinae_friendly_1.cc
CommitLineData
52066eae 1// { dg-do compile { target c++11 } }
ce7f1ce4 2// { dg-additional-options "-Wno-volatile" { target c++2a } }
83ddb39f 3
83ffe9cd 4// Copyright (C) 2012-2023 Free Software Foundation, Inc.
83ddb39f
DK
5//
6// This file is part of the GNU ISO C++ Library. This library is free
7// software; you can redistribute it and/or modify it under the
8// terms of the GNU General Public License as published by the
9// Free Software Foundation; either version 3, or (at your option)
10// any later version.
11
12// This library is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16
17// You should have received a copy of the GNU General Public License along
18// with this library; see the file COPYING3. If not see
19// <http://www.gnu.org/licenses/>.
20
21#include <memory>
22#include <cstddef>
23#include <type_traits>
24
ce7f1ce4 25// Uncomment the following define once gcc has fixed bug 52748
83ddb39f 26// (incomplete types in function call expressions):
ce7f1ce4 27#define HAS_52748_FIXED
83ddb39f
DK
28
29// Helper types:
30struct has_type_impl
31{
b3618b71 32 template<typename T, typename = typename T::type>
83ddb39f
DK
33 static std::true_type test(int);
34
b3618b71 35 template<typename>
83ddb39f
DK
36 static std::false_type test(...);
37};
38
b3618b71
DK
39template<typename T>
40struct has_type : public decltype(has_type_impl::test<T>(0))
83ddb39f
DK
41{};
42
b3618b71
DK
43template<typename T, typename Res>
44struct is_expected_type : public std::is_same<typename T::type, Res>
83ddb39f
DK
45{};
46
b3618b71
DK
47template<typename P1, typename P2>
48struct and_ : public std::conditional<P1::value, P2, std::false_type>::type
49{};
50
51template<typename T, typename Res>
52struct is_type : public and_<has_type<T>, is_expected_type<T, Res>>
83ddb39f
DK
53{};
54
55// Types under inspection:
56
57typedef bool (&PF1)();
58typedef short (*PF2)(long);
59
60struct S {
61 operator PF2() const;
62 double operator()(char, int&);
63 void calc(long) const;
64};
65
66typedef void (S::*PMS)(long) const;
67typedef void (S::*PMSnonconst)(long);
68
69typedef int S::* PMI;
70
71struct B {
72 int i;
73 void f1() const;
74 bool f2(int) const volatile;
75};
76
77struct D : B {};
78
79typedef void (B::*base_func_void)() const;
80typedef bool (B::*base_func_bool_int)(int) const volatile;
81
82struct ident_functor {
b3618b71 83 template<typename T>
83ddb39f
DK
84 T operator()(T&& x);
85};
86
b3618b71 87template<typename Ret = void>
83ddb39f 88struct variable_functor {
b3618b71 89 template<typename... T>
83ddb39f
DK
90 Ret operator()(T&&...);
91};
92
93struct ident_functor_noref {
b3618b71 94 template<typename T>
83ddb39f
DK
95 typename std::remove_reference<T>::type operator()(T&& x);
96};
97
98enum class ScEn;
99
100enum UnScEn : int;
101
102union U {
103 int i;
104 double d;
105};
106
107union U2 {
108 int i;
109 bool b;
110 void operator()() const;
111 int operator()(double) const;
112 bool operator()(double);
113 U operator()(int, int);
114};
115
116struct Ukn;
117
118typedef Ukn (S::*PMSIncomplete)(long) const;
119typedef Ukn (S::*PMSIncompletenonconst)(long);
120typedef Ukn (*FuncIncomplete)(long);
121
122struct Abstract {
123 virtual ~Abstract() = 0;
124};
125
126struct Private {
127private:
128 void operator()();
129 int operator()(int);
130public:
131 bool operator()(std::nullptr_t);
132};
133
134union PrivateUnion {
135 double d;
136private:
137 void operator()();
138 int operator()(int);
139public:
140 bool operator()(std::nullptr_t);
141};
142
b3618b71 143template<typename T>
83ddb39f
DK
144struct ImplicitTo {
145 operator T();
146};
147
b3618b71 148template<typename>
83ddb39f
DK
149struct never { static const bool value = false; };
150
b3618b71 151template<typename T>
83ddb39f
DK
152struct BrokenTrait {
153 static_assert(never<T>::value, "Error!");
154 typedef T type;
155};
156
b3618b71 157template<typename T>
83ddb39f
DK
158struct BadSmartPtr : T {
159 T& operator*() const noexcept(typename BrokenTrait<T>::type());
160};
161
b3618b71 162template<typename Ret>
83ddb39f
DK
163using FuncEllipses = Ret(...);
164
165static_assert(is_type<std::result_of<S(int)>, short>::value, "Error!");
166static_assert(is_type<std::result_of<S&(unsigned char, int&)>,
167 double>::value, "Error!");
168static_assert(is_type<std::result_of<PF1()>, bool>::value, "Error!");
169static_assert(is_type<std::result_of<PF1&()>, bool>::value, "Error!");
170static_assert(is_type<std::result_of<PMS(std::unique_ptr<S>, int)>,
171 void>::value, "Error!");
172static_assert(is_type<std::result_of<PMS(std::unique_ptr<S>&, unsigned&)>,
173 void>::value, "Error!");
174static_assert(is_type<std::result_of<PMS&(std::unique_ptr<S>, int)>,
175 void>::value, "Error!");
176static_assert(is_type<std::result_of<PMS&(std::unique_ptr<S>&, unsigned&)>,
177 void>::value, "Error!");
178
179static_assert(is_type<std::result_of<ident_functor(int)>,
180 int>::value, "Error!");
181static_assert(is_type<std::result_of<ident_functor(const int)>,
182 int>::value, "Error!");
183static_assert(is_type<std::result_of<ident_functor(const int&&)>,
184 int>::value, "Error!");
185static_assert(is_type<std::result_of<ident_functor(int&&)>,
186 int>::value, "Error!");
187static_assert(is_type<std::result_of<ident_functor(int&)>,
188 int&>::value, "Error!");
189
190static_assert(is_type<std::result_of<ident_functor(const B)>,
191 B>::value, "Error!");
192static_assert(is_type<std::result_of<ident_functor(const B&&)>,
193 const B>::value, "Error!");
194static_assert(is_type<std::result_of<ident_functor(B&&)>, B>::value, "Error!");
195static_assert(is_type<std::result_of<ident_functor(B&)>, B&>::value, "Error!");
196
197static_assert(is_type<std::result_of<int B::*(B&)>, int&>::value, "Error!");
198
199// This is expected as of CWG 616 P/R:
200static_assert(is_type<std::result_of<int B::*(B)>, int&&>::value, "Error!");
201
202static_assert(is_type<std::result_of<volatile int B::*(const B&&)>,
203 const volatile int&&>::value, "Error!");
204static_assert(is_type<std::result_of<const int B::*(volatile B&&)>,
205 const volatile int&&>::value, "Error!");
206
207static_assert(is_type<std::result_of<int B::*(const B&)>,
208 const int&>::value, "Error!");
209static_assert(is_type<std::result_of<volatile int B::*(const B&)>,
210 const volatile int&>::value, "Error!");
211static_assert(is_type<std::result_of<const int B::*(volatile B&)>,
212 const volatile int&>::value, "Error!");
213
214static_assert(is_type<std::result_of<int B::*(B*)>, int&>::value, "Error!");
215static_assert(is_type<std::result_of<int B::*(B*&)>, int&>(), "Error!");
216static_assert(is_type<std::result_of<int B::*(const B*)>,
217 const int&>::value, "Error!");
218static_assert(is_type<std::result_of<int B::*(const B*&)>,
219 const int&>::value, "Error!");
220static_assert(is_type<std::result_of<volatile int B::*(const B*)>,
221 const volatile int&>::value, "Error!");
222static_assert(is_type<std::result_of<const int B::*(volatile B*)>,
223 const volatile int&>::value, "Error!");
224
225static_assert(is_type<std::result_of<base_func_void(const B&)>,
226 void>::value, "Error!");
227static_assert(is_type<std::result_of<base_func_void(const B*)>,
228 void>::value, "Error!");
229static_assert(is_type<std::result_of<base_func_void(B&)>,
230 void>::value, "Error!");
231static_assert(is_type<std::result_of<base_func_void(B*)>,
232 void>::value, "Error!");
233
234static_assert(!has_type<std::result_of<base_func_void(volatile B&)>>::value,
235 "Error!");
236static_assert(!has_type<std::result_of<base_func_void(volatile B*)>>::value,
237 "Error!");
238
239static_assert(is_type<std::result_of<base_func_bool_int(B&, long)>,
240 bool>::value, "Error!");
241static_assert(is_type<std::result_of<base_func_bool_int(B*, long)>,
242 bool>::value, "Error!");
243static_assert(is_type<std::result_of<base_func_bool_int(volatile B&, long)>,
244 bool>::value, "Error!");
245static_assert(is_type<std::result_of<base_func_bool_int(volatile B*, long)>,
246 bool>::value, "Error!");
247
248static_assert(!has_type<std::result_of<int()>>(), "Error!");
249static_assert(!has_type<std::result_of<void()>>(), "Error!");
250static_assert(!has_type<std::result_of<int(int)>>(), "Error!");
251static_assert(!has_type<std::result_of<void(int)>>(), "Error!");
252static_assert(!has_type<std::result_of<PF1(int)>>(), "Error!");
253static_assert(is_type<std::result_of<PF2(long)>, short>(), "Error!");
254static_assert(!has_type<std::result_of<PF2()>>(), "Error!");
255static_assert(!has_type<std::result_of<PF2(B)>>(), "Error!");
256static_assert(!has_type<std::result_of<PF2(ScEn)>>(), "Error!");
257static_assert(is_type<std::result_of<PF2(UnScEn)>, short>(), "Error!");
258static_assert(!has_type<std::result_of<PF2(long, int)>>(), "Error!");
259static_assert(is_type<std::result_of<PMS(std::unique_ptr<S>, int)>, void>(),
260 "Error!");
261static_assert(!has_type<std::result_of<PMS(int)>>(), "Error!");
262static_assert(!has_type<std::result_of<PMS(int, std::unique_ptr<S>)>>(), "Error!");
263
264// Argument number mismatch:
265static_assert(!has_type<std::result_of<PMS(std::unique_ptr<S>)>>(), "Error!");
266static_assert(!has_type<std::result_of<PMS(std::unique_ptr<S>&)>>(), "Error!");
267static_assert(!has_type<std::result_of<PMS(std::unique_ptr<S>, int, bool)>>(),
268 "Error!");
269static_assert(!has_type<std::result_of<PMS(std::unique_ptr<S>&, int, bool)>>(),
270 "Error!");
271static_assert(!has_type<std::result_of<PMS(S)>>(), "Error!");
272static_assert(!has_type<std::result_of<PMS(S&)>>(), "Error!");
273static_assert(!has_type<std::result_of<PMS(S, int, bool)>>(), "Error!");
274static_assert(!has_type<std::result_of<PMS(S&, int, bool)>>(), "Error!");
275
276// Non-convertible arguments:
277static_assert(!has_type<std::result_of<PMS(std::unique_ptr<S>, S)>>(),
278 "Error!");
279static_assert(!has_type<std::result_of<PMS(std::unique_ptr<S>&, S)>>(),
280 "Error!");
281static_assert(!has_type<std::result_of<PMS(S, S)>>(), "Error!");
282static_assert(!has_type<std::result_of<PMS(S&, S)>>(), "Error!");
283
284// cv-violations:
285static_assert(!has_type<std::result_of<PMSnonconst(const S&, long)>>(),
286 "Error!");
287static_assert(!has_type<std::result_of<PMSnonconst(const S&&, long)>>(),
288 "Error!");
289static_assert(!has_type<std::result_of<PMSnonconst(const S*, long)>>(),
290 "Error!");
291static_assert(!has_type<std::result_of<PMSnonconst(const S*&, long)>>(),
292 "Error!");
293
294static_assert(is_type<std::result_of<PMI(S*)>, int&>(), "Error!");
295static_assert(is_type<std::result_of<PMI(S&)>, int&>(), "Error!");
296static_assert(is_type<std::result_of<PMI(S&&)>, int&&>(), "Error!");
297static_assert(is_type<std::result_of<PMI(S)>, int&&>(), "Error!");
298
299static_assert(!has_type<std::result_of<PMI()>>(), "Error!");
300
301static_assert(!has_type<std::result_of<PMI(S*, int)>>(), "Error!");
302static_assert(!has_type<std::result_of<PMI(S&, int)>>(), "Error!");
303static_assert(!has_type<std::result_of<PMI(S*, int, S, bool)>>(), "Error!");
304static_assert(!has_type<std::result_of<PMI(S&, int, S, bool)>>(), "Error!");
305
306static_assert(!has_type<std::result_of<PMI(B*)>>(), "Error!");
307static_assert(!has_type<std::result_of<PMI(B&)>>(), "Error!");
308
309static_assert(is_type<std::result_of<int U::*(U)>, int&&>(), "Error!");
310static_assert(is_type<std::result_of<int U::*(U&)>, int&>(), "Error!");
311static_assert(is_type<std::result_of<int U::*(const U&)>, const int&>(),
312 "Error!");
313static_assert(is_type<std::result_of
314 <volatile int U::*(const U&)>, const volatile int&>(), "Error!");
315static_assert(is_type<std::result_of
316 <const int U::*(volatile U&)>, const volatile int&>(), "Error!");
317
318static_assert(is_type<std::result_of<int Ukn::*(Ukn*)>, int&>(), "Error!");
319static_assert(is_type<std::result_of<int Ukn::*(Ukn&)>, int&>(), "Error!");
320static_assert(is_type<std::result_of<int Ukn::*(Ukn&&)>, int&&>(), "Error!");
321static_assert(is_type<std::result_of<int Ukn::*(const Ukn*)>, const int&>(),
322 "Error!");
323static_assert(is_type<std::result_of<int Ukn::*(const Ukn&)>, const int&>(),
324 "Error!");
325static_assert(is_type<std::result_of<int Ukn::*(const Ukn&&)>, const int&&>(),
326 "Error!");
327
328typedef void (Ukn::* PUfnMF)();
329typedef void (Ukn::* PUfnConstMF)() const;
330
331static_assert(is_type<std::result_of<PUfnMF(Ukn*)>, void>(), "Error!");
332static_assert(is_type<std::result_of<PUfnMF(Ukn&)>, void>(), "Error!");
333static_assert(is_type<std::result_of<PUfnMF(Ukn&&)>, void>(), "Error!");
334static_assert(is_type<std::result_of<PUfnConstMF(Ukn*)>, void>(), "Error!");
335static_assert(is_type<std::result_of<PUfnConstMF(Ukn&)>, void>(), "Error!");
336static_assert(is_type<std::result_of<PUfnConstMF(Ukn&&)>, void>(), "Error!");
337static_assert(is_type<std::result_of<PUfnConstMF(const Ukn*)>, void>(),
338 "Error!");
339static_assert(is_type<std::result_of<PUfnConstMF(const Ukn&)>, void>(),
340 "Error!");
341static_assert(is_type<std::result_of<PUfnConstMF(const Ukn&&)>, void>(),
342 "Error!");
343
344static_assert(!has_type<std::result_of<S()>>(), "Error!");
345static_assert(!has_type<std::result_of<S(int, S)>>(), "Error!");
346static_assert(!has_type<std::result_of<S(S)>>(), "Error!");
347static_assert(!has_type<std::result_of
348 <S(double, bool, std::nullptr_t, Ukn&)>>(), "Error!");
349
350static_assert(is_type<std::result_of<U2()>, void>(), "Error!");
351static_assert(is_type<std::result_of<const U2&()>, void>(), "Error!");
352static_assert(is_type<std::result_of<U2&()>, void>(), "Error!");
353static_assert(is_type<std::result_of<U2(double)>, bool>(), "Error!");
354static_assert(is_type<std::result_of<const U2&(double)>, int>(), "Error!");
355static_assert(is_type<std::result_of<U2&(double)>, bool>(), "Error!");
356static_assert(is_type<std::result_of<U2(int)>, bool>(), "Error!");
357static_assert(is_type<std::result_of<U2&(int)>, bool>(), "Error!");
358static_assert(is_type<std::result_of<const U2&(int)>, int>(), "Error!");
359static_assert(is_type<std::result_of<U2(int, int)>, U>(), "Error!");
360static_assert(is_type<std::result_of<U2&(int, int)>, U>(), "Error!");
361
362static_assert(!has_type<std::result_of<const U2&(int, int)>>(), "Error!");
363static_assert(!has_type<std::result_of<U2(int, int, int)>>(), "Error!");
364static_assert(!has_type<std::result_of<U2&(int, int, int)>>(), "Error!");
365static_assert(!has_type<std::result_of<const U2&(int, int, int)>>(), "Error!");
366
367static_assert(is_type<std::result_of<ident_functor(int)>, int>(), "Error!");
368static_assert(is_type<std::result_of<ident_functor(const volatile int)>,
369 int>(), "Error!");
370static_assert(is_type<std::result_of<ident_functor(int&)>, int&>(), "Error!");
371static_assert(is_type<std::result_of<ident_functor(const volatile int&)>,
372 const volatile int&>(), "Error!");
373static_assert(is_type<std::result_of<ident_functor(int&&)>, int>(), "Error!");
374static_assert(is_type<std::result_of<ident_functor(const volatile int&&)>,
375 int>(), "Error!");
376static_assert(is_type<std::result_of<ident_functor(Abstract&)>, Abstract&>(),
377 "Error!");
378static_assert(is_type<std::result_of<ident_functor(const volatile Abstract&)>,
379 const volatile Abstract&>(), "Error!");
380
381static_assert(!has_type<std::result_of<ident_functor(int(&&)[1])>>(), "Error!");
baf38d2e 382static_assert(is_type<std::result_of<ident_functor(Abstract&&)>,Abstract>(), "Error!");
83ddb39f
DK
383static_assert(!has_type<std::result_of<ident_functor(const int(&&)[1])>>(),
384 "Error!");
baf38d2e 385static_assert(is_type<std::result_of<ident_functor(const Abstract&&)>,const Abstract>(),
83ddb39f
DK
386 "Error!");
387static_assert(!has_type<std::result_of<ident_functor_noref(int(&)[1])>>(),
388 "Error!");
389static_assert(!has_type<std::result_of<ident_functor_noref
390 (const int(&)[1])>>(), "Error!");
baf38d2e 391static_assert(is_type<std::result_of<ident_functor_noref(Abstract&)>,Abstract>(),
83ddb39f 392 "Error!");
baf38d2e
JM
393static_assert(is_type<std::result_of
394 <ident_functor_noref(const Abstract&)>,const Abstract>(), "Error!");
83ddb39f
DK
395static_assert(!has_type<std::result_of<ident_functor_noref(void(&)())>>(),
396 "Error!");
397static_assert(!has_type<std::result_of<ident_functor_noref(void(&&)())>>(),
398 "Error!");
399
400static_assert(!has_type<std::result_of<ident_functor()>>(), "Error!");
401static_assert(!has_type<std::result_of<ident_functor(int, int)>>(), "Error!");
402static_assert(!has_type<std::result_of<const ident_functor&(int)>>(), "Error!");
403static_assert(!has_type<std::result_of<const ident_functor&&(int)>>(),
404 "Error!");
405
406// Border-line case:
407static_assert(!has_type<std::result_of<int S::*(Ukn*)>>(), "Error!");
408static_assert(!has_type<std::result_of<void (S::*(Ukn*))()>>(), "Error!");
409
410// We want to allow this, it seems to be required by the order described
411// in [func.require] p1:
412static_assert(is_type<std::result_of<int S::*(BadSmartPtr<S>&)>, int&>(),
413 "Error!");
414
415static_assert(is_type<std::result_of<Private(std::nullptr_t)>, bool>(),
416 "Error!");
417static_assert(is_type<std::result_of<Private&(std::nullptr_t)>, bool>(),
418 "Error!");
419static_assert(is_type<std::result_of<Private&&(std::nullptr_t)>, bool>(),
420 "Error!");
421static_assert(is_type<std::result_of<Private(ImplicitTo<std::nullptr_t>)>,
422 bool>(), "Error!");
423static_assert(is_type<std::result_of<Private&(ImplicitTo<std::nullptr_t>)>,
424 bool>(), "Error!");
425static_assert(is_type<std::result_of<Private&&(ImplicitTo<std::nullptr_t>)>,
426 bool>(), "Error!");
427
428static_assert(!has_type<std::result_of<const Private&(std::nullptr_t)>>(),
429 "Error!");
430static_assert(!has_type<std::result_of<const Private&&(std::nullptr_t)>>(),
431 "Error!");
432static_assert(!has_type<std::result_of<Private()>>(), "Error!");
433static_assert(!has_type<std::result_of<Private(int)>>(), "Error!");
434static_assert(!has_type<std::result_of<Private(int, int)>>(), "Error!");
435static_assert(!has_type<std::result_of<Private&()>>(), "Error!");
436static_assert(!has_type<std::result_of<Private&(int)>>(), "Error!");
437static_assert(!has_type<std::result_of<Private&(int, int)>>(), "Error!");
438static_assert(!has_type<std::result_of<const Private&()>>(), "Error!");
439static_assert(!has_type<std::result_of<const Private&(int)>>(), "Error!");
440static_assert(!has_type<std::result_of<const Private&(int, int)>>(), "Error!");
441static_assert(!has_type<std::result_of<Private&&()>>(), "Error!");
442static_assert(!has_type<std::result_of<Private&&(int)>>(), "Error!");
443static_assert(!has_type<std::result_of<Private&&(int, int)>>(), "Error!");
444static_assert(!has_type<std::result_of<const Private&&()>>(), "Error!");
445static_assert(!has_type<std::result_of<const Private&&(int)>>(), "Error!");
446static_assert(!has_type<std::result_of<const Private&&(int, int)>>(), "Error!");
447
448static_assert(!has_type<std::result_of<Private(ScEn)>>(), "Error!");
449static_assert(!has_type<std::result_of<Private(UnScEn)>>(), "Error!");
450static_assert(!has_type<std::result_of<const Private&(ScEn)>>(), "Error!");
451static_assert(!has_type<std::result_of<const Private&(UnScEn)>>(), "Error!");
452static_assert(!has_type<std::result_of<Private(ImplicitTo<ScEn>)>>(), "Error!");
453static_assert(!has_type<std::result_of<Private(ImplicitTo<UnScEn>)>>(),
454 "Error!");
455static_assert(!has_type<std::result_of<const Private&(ImplicitTo<ScEn>)>>(),
456 "Error!");
457static_assert(!has_type<std::result_of<const Private&(ImplicitTo<UnScEn>)>>(),
458 "Error!");
459
460static_assert(is_type<std::result_of<PrivateUnion(std::nullptr_t)>, bool>(),
461 "Error!");
462static_assert(is_type<std::result_of<PrivateUnion&(std::nullptr_t)>, bool>(),
463 "Error!");
464static_assert(is_type<std::result_of<PrivateUnion&&(std::nullptr_t)>, bool>(),
465 "Error!");
466static_assert(is_type<std::result_of<PrivateUnion(ImplicitTo<std::nullptr_t>)>,
467 bool>(), "Error!");
468static_assert(is_type<std::result_of
469 <PrivateUnion&(ImplicitTo<std::nullptr_t>)>, bool>(), "Error!");
470static_assert(is_type<std::result_of
471 <PrivateUnion&&(ImplicitTo<std::nullptr_t>)>, bool>(), "Error!");
472
473static_assert(!has_type<std::result_of<const PrivateUnion&(std::nullptr_t)>>(),
474 "Error!");
475static_assert(!has_type<std::result_of
476 <const PrivateUnion&&(std::nullptr_t)>>(), "Error!");
477static_assert(!has_type<std::result_of<PrivateUnion()>>(), "Error!");
478static_assert(!has_type<std::result_of<PrivateUnion(int)>>(), "Error!");
479static_assert(!has_type<std::result_of<PrivateUnion(int, int)>>(), "Error!");
480static_assert(!has_type<std::result_of<PrivateUnion&()>>(), "Error!");
481static_assert(!has_type<std::result_of<PrivateUnion&(int)>>(), "Error!");
482static_assert(!has_type<std::result_of<PrivateUnion&(int, int)>>(), "Error!");
483static_assert(!has_type<std::result_of<const PrivateUnion&()>>(), "Error!");
484static_assert(!has_type<std::result_of<const PrivateUnion&(int)>>(), "Error!");
485static_assert(!has_type<std::result_of<const PrivateUnion&(int, int)>>(),
486 "Error!");
487static_assert(!has_type<std::result_of<PrivateUnion&&()>>(), "Error!");
488static_assert(!has_type<std::result_of<PrivateUnion&&(int)>>(), "Error!");
489static_assert(!has_type<std::result_of<PrivateUnion&&(int, int)>>(), "Error!");
490static_assert(!has_type<std::result_of<const PrivateUnion&&()>>(), "Error!");
491static_assert(!has_type<std::result_of<const PrivateUnion&&(int)>>(), "Error!");
492static_assert(!has_type<std::result_of<const PrivateUnion&&(int, int)>>(),
493 "Error!");
494
495static_assert(!has_type<std::result_of<PrivateUnion(ScEn)>>(), "Error!");
496static_assert(!has_type<std::result_of<PrivateUnion(UnScEn)>>(), "Error!");
497static_assert(!has_type<std::result_of<const PrivateUnion&(ScEn)>>(), "Error!");
498static_assert(!has_type<std::result_of<const PrivateUnion&(UnScEn)>>(),
499 "Error!");
500static_assert(!has_type<std::result_of<PrivateUnion(ImplicitTo<ScEn>)>>(),
501 "Error!");
502static_assert(!has_type<std::result_of<PrivateUnion(ImplicitTo<UnScEn>)>>(),
503 "Error!");
504static_assert(!has_type<std::result_of
505 <const PrivateUnion&(ImplicitTo<ScEn>)>>(), "Error!");
506static_assert(!has_type<std::result_of
507 <const PrivateUnion&(ImplicitTo<UnScEn>)>>(), "Error!");
508
509static_assert(is_type<std::result_of<void(*(bool))(int)>, void>(), "Error!");
510static_assert(is_type<std::result_of<void(*(UnScEn))(int)>, void>(), "Error!");
511static_assert(is_type<std::result_of<void(*(ImplicitTo<int>))(int)>, void>(),
512 "Error!");
513static_assert(is_type<std::result_of<void(*(ImplicitTo<int>&))(int)>, void>(),
514 "Error!");
515static_assert(is_type<std::result_of<void(*(ImplicitTo<int>&&))(int)>, void>(),
516 "Error!");
517
518static_assert(!has_type<std::result_of<void(*(ScEn))(int)>>(), "Error!");
519static_assert(!has_type<std::result_of
520 <void(*(const ImplicitTo<int>&))(int)>>(), "Error!");
521static_assert(!has_type<std::result_of
522 <void(*(const ImplicitTo<int>&&))(int)>>(), "Error!");
523
524static_assert(is_type<std::result_of<ImplicitTo<void(*)()>()>, void>(),
525 "Error!");
526static_assert(is_type<std::result_of<ImplicitTo<void(&)()>()>, void>(),
527 "Error!");
528
529static_assert(!has_type<std::result_of<ImplicitTo<void(*)()>(int)>>(),
530 "Error!");
531static_assert(!has_type<std::result_of<ImplicitTo<void(*)(int)>()>>(),
532 "Error!");
533static_assert(!has_type<std::result_of<ImplicitTo<void(&)()>(int)>>(),
534 "Error!");
535static_assert(!has_type<std::result_of<ImplicitTo<void(&)(int)>()>>(),
536 "Error!");
537
538// Conversion operators of types are not considered in call expressions
539// (except for conversion to function pointer/reference):
540static_assert(!has_type<std::result_of<ImplicitTo<S>(char, int&)>>(), "Error!");
541static_assert(!has_type<std::result_of<ImplicitTo<ident_functor>(int)>>(),
542 "Error!");
543
544static_assert(is_type<std::result_of<variable_functor<>()>, void>(), "Error!");
545static_assert(is_type<std::result_of<variable_functor<>(int)>, void>(),
546 "Error!");
547static_assert(is_type<std::result_of<variable_functor<>(int, int)>, void>(),
548 "Error!");
549static_assert(is_type<std::result_of<variable_functor<>(int, int, int)>,
550 void>(), "Error!");
551
552static_assert(is_type<std::result_of<variable_functor<>&()>, void>(), "Error!");
553static_assert(is_type<std::result_of<variable_functor<>&(int)>, void>(),
554 "Error!");
555static_assert(is_type<std::result_of<variable_functor<>&(int, int)>, void>(),
556 "Error!");
557static_assert(is_type<std::result_of<variable_functor<>&(int, int, int)>,
558 void>(), "Error!");
559
560static_assert(!has_type<std::result_of<const variable_functor<>()>>(),
561 "Error!");
562static_assert(!has_type<std::result_of<const variable_functor<>(int)>>(),
563 "Error!");
564static_assert(!has_type<std::result_of<const variable_functor<>(int, int)>>(),
565 "Error!");
566static_assert(!has_type<std::result_of
567 <const variable_functor<>(int, int, int)>>(), "Error!");
568
569static_assert(!has_type<std::result_of<const variable_functor<>&()>>(),
570 "Error!");
571static_assert(!has_type<std::result_of<const variable_functor<>&(int)>>(),
572 "Error!");
573static_assert(!has_type<std::result_of
574 <const variable_functor<>&(int, int)>>(), "Error!");
575static_assert(!has_type<std::result_of
576 <const variable_functor<>&(int, int, int)>>(), "Error!");
577
578static_assert(is_type<std::result_of<variable_functor<S>()>, S>(), "Error!");
579static_assert(is_type<std::result_of<variable_functor<S>(int)>, S>(), "Error!");
580static_assert(is_type<std::result_of<variable_functor<S>(int, int)>, S>(),
581 "Error!");
582static_assert(is_type<std::result_of<variable_functor<S>(int, int, int)>, S>(),
583 "Error!");
584
585static_assert(is_type<std::result_of<variable_functor<S>&()>, S>(), "Error!");
586static_assert(is_type<std::result_of<variable_functor<S>&(int)>, S>(),
587 "Error!");
588static_assert(is_type<std::result_of<variable_functor<S>&(int, int)>, S>(),
589 "Error!");
590static_assert(is_type<std::result_of
591 <variable_functor<S>&(int, int, int)>, S>(), "Error!");
592
593static_assert(!has_type<std::result_of
594 <const variable_functor<S>()>>(), "Error!");
595static_assert(!has_type<std::result_of
596 <const variable_functor<S>(int)>>(), "Error!");
597static_assert(!has_type<std::result_of
598 <const variable_functor<S>(int, int)>>(), "Error!");
599static_assert(!has_type<std::result_of
600 <const variable_functor<S>(int, int, int)>>(), "Error!");
601
602static_assert(!has_type<std::result_of<const variable_functor<S>&()>>(),
603 "Error!");
604static_assert(!has_type<std::result_of<const variable_functor<S>&(int)>>(),
605 "Error!");
606static_assert(!has_type<std::result_of
607 <const variable_functor<S>&(int, int)>>(), "Error!");
608static_assert(!has_type<std::result_of
609 <const variable_functor<S>&(int, int, int)>>(), "Error!");
610
611#if defined(HAS_52748_FIXED)
612static_assert(has_type<std::result_of<variable_functor<Ukn>()>>(), "Error!");
613static_assert(is_type<std::result_of<variable_functor<Ukn>()>, Ukn>(),
614 "Error!");
615static_assert(is_type<std::result_of<variable_functor<Ukn>(int)>, Ukn>(),
616 "Error!");
617static_assert(is_type<std::result_of<variable_functor<Ukn>(int, int)>, Ukn>(),
618 "Error!");
619static_assert(is_type<std::result_of
620 <variable_functor<Ukn>(int, int, int)>, Ukn>(), "Error!");
621
622static_assert(is_type<std::result_of<variable_functor<Ukn>&()>, Ukn>(),
623 "Error!");
624static_assert(is_type<std::result_of<variable_functor<Ukn>&(int)>, Ukn>(),
625 "Error!");
626static_assert(is_type<std::result_of
627 <variable_functor<Ukn>&(int, int)>, Ukn>(), "Error!");
628static_assert(is_type<std::result_of
629 <variable_functor<Ukn>&(int, int, int)>, Ukn>(), "Error!");
630
ce7f1ce4
JW
631static_assert(is_type<std::result_of<PMSIncomplete(S*, int)>, Ukn>(), "Error!");
632static_assert(is_type<std::result_of<PMSIncomplete&(const S&, int)>, Ukn>(), "Error!");
633static_assert(is_type<std::result_of<PMSIncomplete&&(S&&, int)>, Ukn>(), "Error!");
83ddb39f
DK
634
635static_assert(is_type<std::result_of<FuncIncomplete(int)>, Ukn>(), "Error!");
636static_assert(is_type<std::result_of<FuncIncomplete&(int)>, Ukn>(), "Error!");
637static_assert(is_type<std::result_of<FuncIncomplete&&(int)>, Ukn>(), "Error!");
638
639static_assert(is_type<std::result_of<FuncEllipses<Ukn>*()>, Ukn>(), "Error!");
640static_assert(is_type<std::result_of<FuncEllipses<Ukn>&()>, Ukn>(), "Error!");
641static_assert(is_type<std::result_of<FuncEllipses<Ukn>&&()>, Ukn>(), "Error!");
642
643static_assert(is_type<std::result_of<FuncEllipses<Ukn>*(bool)>, Ukn>(),
644 "Error!");
645static_assert(is_type<std::result_of<FuncEllipses<Ukn>&(bool)>, Ukn>(),
646 "Error!");
647static_assert(is_type<std::result_of<FuncEllipses<Ukn>&&(bool)>, Ukn>(),
648 "Error!");
649
650static_assert(is_type<std::result_of<FuncEllipses<Ukn>*(bool, int, S)>, Ukn>(),
651 "Error!");
652static_assert(is_type<std::result_of<FuncEllipses<Ukn>&(bool, int, S)>, Ukn>(),
653 "Error!");
654static_assert(is_type<std::result_of
655 <FuncEllipses<Ukn>&&(bool, int, S)>, Ukn>(), "Error!");
656
657static_assert(!has_type<std::result_of<PMSIncompletenonconst(const S*)>>(),
658 "Error!");
659static_assert(!has_type<std::result_of
660 <PMSIncompletenonconst(const S*, int)>>(), "Error!");
661static_assert(!has_type<std::result_of
662 <PMSIncompletenonconst(const S*, int, int)>>(), "Error!");
663static_assert(!has_type<std::result_of
664 <PMSIncompletenonconst(const S*, int, int, int)>>(), "Error!");
665static_assert(!has_type<std::result_of
666 <PMSIncompletenonconst(const S*&)>>(), "Error!");
667static_assert(!has_type<std::result_of
668 <PMSIncompletenonconst(const S*&, int)>>(), "Error!");
669static_assert(!has_type<std::result_of
670 <PMSIncompletenonconst(const S*&, int, int)>>(), "Error!");
671static_assert(!has_type<std::result_of
672 <PMSIncompletenonconst(const S*&, int, int, int)>>(), "Error!");
673
674static_assert(!has_type<std::result_of
675 <PMSIncompletenonconst(const S&)>>(), "Error!");
676static_assert(!has_type<std::result_of
677 <PMSIncompletenonconst(const S&, int)>>(), "Error!");
678static_assert(!has_type<std::result_of
679 <PMSIncompletenonconst(const S&, int, int)>>(), "Error!");
680static_assert(!has_type<std::result_of
681 <PMSIncompletenonconst(const S&, int, int, int)>>(), "Error!");
682static_assert(!has_type<std::result_of
683 <PMSIncompletenonconst(const S&&)>>(), "Error!");
684static_assert(!has_type<std::result_of
685 <PMSIncompletenonconst(const S&&, int)>>(), "Error!");
686static_assert(!has_type<std::result_of
687 <PMSIncompletenonconst(const S&&, int, int)>>(), "Error!");
688static_assert(!has_type<std::result_of
689 <PMSIncompletenonconst(const S&&, int, int, int)>>(), "Error!");
690#endif
691
692static_assert(!has_type<std::result_of<const variable_functor<Ukn>()>>(),
693 "Error!");
694static_assert(!has_type<std::result_of<const variable_functor<Ukn>(int)>>(),
695 "Error!");
696static_assert(!has_type<std::result_of
697 <const variable_functor<Ukn>(int, int)>>(), "Error!");
698static_assert(!has_type<std::result_of
699 <const variable_functor<Ukn>(int, int, int)>>(), "Error!");
700
701static_assert(!has_type<std::result_of<const variable_functor<Ukn>&()>>(),
702 "Error!");
703static_assert(!has_type<std::result_of<const variable_functor<Ukn>&(int)>>(),
704 "Error!");
705static_assert(!has_type<std::result_of
706 <const variable_functor<Ukn>&(int, int)>>(), "Error!");
707static_assert(!has_type<std::result_of
708 <const variable_functor<Ukn>&(int, int, int)>>(), "Error!");
709
710static_assert(!has_type<std::result_of<FuncIncomplete()>>(), "Error!");
711static_assert(!has_type<std::result_of<FuncIncomplete(S)>>(), "Error!");
712static_assert(!has_type<std::result_of<FuncIncomplete(int, int)>>(), "Error!");
713static_assert(!has_type<std::result_of<FuncIncomplete(int, int, int)>>(),
714 "Error!");
715
716static_assert(!has_type<std::result_of<FuncIncomplete&&()>>(), "Error!");
717static_assert(!has_type<std::result_of<FuncIncomplete&&(S)>>(), "Error!");
718static_assert(!has_type<std::result_of<FuncIncomplete&&(int, int)>>(),
719 "Error!");
720static_assert(!has_type<std::result_of<FuncIncomplete&&(int, int, int)>>(),
721 "Error!");
722
723static_assert(is_type<std::result_of<FuncEllipses<int>*()>, int>(), "Error!");
724static_assert(is_type<std::result_of<FuncEllipses<int>&()>, int>(), "Error!");
725static_assert(is_type<std::result_of<FuncEllipses<int>&&()>, int>(), "Error!");
726
727static_assert(is_type<std::result_of<FuncEllipses<int>*(bool)>, int>(),
728 "Error!");
729static_assert(is_type<std::result_of<FuncEllipses<int>&(bool)>, int>(),
730 "Error!");
731static_assert(is_type<std::result_of<FuncEllipses<int>&&(bool)>, int>(),
732 "Error!");
733
734static_assert(is_type<std::result_of<FuncEllipses<int>*(bool, int, S)>, int>(),
735 "Error!");
736static_assert(is_type<std::result_of<FuncEllipses<int>&(bool, int, S)>, int>(),
737 "Error!");
738static_assert(is_type<std::result_of
739 <FuncEllipses<int>&&(bool, int, S)>, int>(), "Error!");
740