Debian Codegraph @

gcc/testsuite/g++.dg/ext/is_nothrow_invocable.C

raw
1 // { dg-do compile { target c++11 } }
2
3 #define SA(X) static_assert((X),#X)
4
5 using func_type = void(*)();
6 SA( ! __is_nothrow_invocable(func_type) );
7
8 #if __cpp_noexcept_function_type
9 using func_type_nt = void(*)() noexcept;
10 SA( __is_nothrow_invocable(func_type_nt) );
11 #endif
12
13 struct X { };
14 using mem_type = int X::*;
15
16 SA( ! __is_nothrow_invocable(mem_type) );
17 SA( ! __is_nothrow_invocable(mem_type, int) );
18 SA( ! __is_nothrow_invocable(mem_type, int&) );
19 SA( __is_nothrow_invocable(mem_type, X&) );
20
21 using memfun_type = int (X::*)();
22
23 SA( ! __is_nothrow_invocable(memfun_type) );
24 SA( ! __is_nothrow_invocable(memfun_type, int) );
25 SA( ! __is_nothrow_invocable(memfun_type, int&) );
26 SA( ! __is_nothrow_invocable(memfun_type, X&) );
27 SA( ! __is_nothrow_invocable(memfun_type, X*) );
28
29 #if __cpp_noexcept_function_type
30 using memfun_type_nt = int (X::*)() noexcept;
31
32 SA( ! __is_nothrow_invocable(memfun_type_nt) );
33 SA( ! __is_nothrow_invocable(memfun_type_nt, int) );
34 SA( ! __is_nothrow_invocable(memfun_type_nt, int&) );
35 SA( __is_nothrow_invocable(memfun_type_nt, X&) );
36 SA( __is_nothrow_invocable(memfun_type_nt, X*) );
37 #endif
38
39 struct F {
40 int& operator()();
41 long& operator()() const noexcept;
42 short& operator()(int) &&;
43 char& operator()(int) const& noexcept;
44 private:
45 void operator()(int, int) noexcept;
46 };
47 using CF = const F;
48
49 SA( ! __is_nothrow_invocable(F ) );
50 SA( __is_nothrow_invocable(CF) );
51
52 SA( ! __is_nothrow_invocable(F, int) );
53 SA( __is_nothrow_invocable(F&, int) );
54
55 SA( __is_nothrow_invocable(CF, int) );
56 SA( __is_nothrow_invocable(CF&, int) );
57 SA( ! __is_nothrow_invocable(F, int, int) );
58
59 struct FX {
60 X operator()() const noexcept { return {}; }
61 };
62 SA( __is_nothrow_invocable(FX) );