| 1 |
// P0847R7 |
| 2 |
// { dg-do compile { target c++23 } } |
| 3 |
|
| 4 |
// operators that are not required to be members |
| 5 |
// called in a non-dependent context |
| 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 |
void do_calls() |
| 15 |
{ |
| 16 |
Value value{}; |
| 17 |
TEST_OPS(value) |
| 18 |
TEST_OPS(static_cast<Value&&>(value)) |
| 19 |
TEST_OPS(static_cast<Value const&>(value)) |
| 20 |
TEST_OPS(static_cast<Value const&&>(value)) |
| 21 |
|
| 22 |
LRef l_ref{}; |
| 23 |
TEST_OPS(l_ref) |
| 24 |
TEST_INVALID(static_cast<LRef&&>(l_ref)) |
| 25 |
TEST_INVALID(static_cast<LRef const&>(l_ref)) |
| 26 |
TEST_INVALID(static_cast<LRef const&&>(l_ref)) |
| 27 |
|
| 28 |
RRef r_ref{}; |
| 29 |
TEST_INVALID(r_ref) |
| 30 |
TEST_OPS(static_cast<RRef&&>(r_ref)) |
| 31 |
TEST_INVALID(static_cast<RRef const&>(r_ref)) |
| 32 |
TEST_INVALID(static_cast<RRef const&&>(r_ref)) |
| 33 |
|
| 34 |
ConstLRef const_l_ref{}; |
| 35 |
TEST_OPS(const_l_ref) |
| 36 |
TEST_OPS(static_cast<ConstLRef&&>(const_l_ref)) |
| 37 |
TEST_OPS(static_cast<ConstLRef const&>(const_l_ref)) |
| 38 |
TEST_OPS(static_cast<ConstLRef const&&>(const_l_ref)) |
| 39 |
|
| 40 |
ConstRRef const_r_ref{}; |
| 41 |
TEST_INVALID(const_r_ref) |
| 42 |
TEST_OPS(static_cast<ConstRRef&&>(const_r_ref)) |
| 43 |
TEST_INVALID(static_cast<ConstRRef const&>(const_r_ref)) |
| 44 |
TEST_OPS(static_cast<ConstRRef const&&>(const_r_ref)) |
| 45 |
|
| 46 |
Deduced deduced{}; |
| 47 |
TEST_OPS(deduced) |
| 48 |
TEST_OPS(static_cast<Deduced&&>(deduced)) |
| 49 |
TEST_OPS(static_cast<Deduced const&>(deduced)) |
| 50 |
TEST_OPS(static_cast<Deduced const&&>(deduced)) |
| 51 |
|
| 52 |
VALIDATE_RETURN_TYPES(deduced, Deduced&) |
| 53 |
VALIDATE_RETURN_TYPES(static_cast<Deduced&&>(deduced), Deduced&&) |
| 54 |
VALIDATE_RETURN_TYPES(static_cast<Deduced const&>(deduced), Deduced const&) |
| 55 |
VALIDATE_RETURN_TYPES(static_cast<Deduced const&&>(deduced), Deduced const&&) |
| 56 |
} |
| 57 |
|