Debian Codegraph @

gcc/testsuite/g++.dg/cpp23/explicit-obj-ops-non-mem-dep.C

raw
1 // P0847R7
2 // { dg-do compile { target c++23 } }
3
4 // operators that are not required to be members
5 // called in a dependent context (as non dependent exprs)
6 // see header
7 #include "explicit-obj-ops-non-mem.h"
8
9 // noop, indicates which versions are ill-formed
10 // I could not find a way to test the invalid cases
11 // without requires expressions
12 #define TEST_INVALID(X)
13
14 template<typename T = void>
15 void do_calls()
16 {
17 Value value{};
18 TEST_OPS(value)
19 TEST_OPS(static_cast<Value&&>(value))
20 TEST_OPS(static_cast<Value const&>(value))
21 TEST_OPS(static_cast<Value const&&>(value))
22
23 LRef l_ref{};
24 TEST_OPS(l_ref)
25 TEST_INVALID(static_cast<LRef&&>(l_ref))
26 TEST_INVALID(static_cast<LRef const&>(l_ref))
27 TEST_INVALID(static_cast<LRef const&&>(l_ref))
28
29 RRef r_ref{};
30 TEST_INVALID(r_ref)
31 TEST_OPS(static_cast<RRef&&>(r_ref))
32 TEST_INVALID(static_cast<RRef const&>(r_ref))
33 TEST_INVALID(static_cast<RRef const&&>(r_ref))
34
35 ConstLRef const_l_ref{};
36 TEST_OPS(const_l_ref)
37 TEST_OPS(static_cast<ConstLRef&&>(const_l_ref))
38 TEST_OPS(static_cast<ConstLRef const&>(const_l_ref))
39 TEST_OPS(static_cast<ConstLRef const&&>(const_l_ref))
40
41 ConstRRef const_r_ref{};
42 TEST_INVALID(const_r_ref)
43 TEST_OPS(static_cast<ConstRRef&&>(const_r_ref))
44 TEST_INVALID(static_cast<ConstRRef const&>(const_r_ref))
45 TEST_OPS(static_cast<ConstRRef const&&>(const_r_ref))
46
47 Deduced deduced{};
48 TEST_OPS(deduced)
49 TEST_OPS(static_cast<Deduced&&>(deduced))
50 TEST_OPS(static_cast<Deduced const&>(deduced))
51 TEST_OPS(static_cast<Deduced const&&>(deduced))
52
53 VALIDATE_RETURN_TYPES(deduced, Deduced&)
54 VALIDATE_RETURN_TYPES(static_cast<Deduced&&>(deduced), Deduced&&)
55 VALIDATE_RETURN_TYPES(static_cast<Deduced const&>(deduced), Deduced const&)
56 VALIDATE_RETURN_TYPES(static_cast<Deduced const&&>(deduced), Deduced const&&)
57 }
58