| 1 |
// P0847R7 |
| 2 |
// { dg-do compile { target c++23 } } |
| 3 |
|
| 4 |
// instantiating captureless lambda call operator with unrelated explicit object parameter |
| 5 |
|
| 6 |
void test0() |
| 7 |
{ |
| 8 |
auto f0 = [](this auto self) { return self; }; |
| 9 |
auto fp0_value = static_cast<int(*)(int) >(&decltype(f0)::operator()); |
| 10 |
auto fp0_lref = static_cast<int(*)(int&) >(&decltype(f0)::operator()); |
| 11 |
auto fp0_rref = static_cast<int(*)(int&&) >(&decltype(f0)::operator()); |
| 12 |
auto fp0_constlref = static_cast<int(*)(int const&) >(&decltype(f0)::operator()); |
| 13 |
auto fp0_constrref = static_cast<int(*)(int const&&)>(&decltype(f0)::operator()); |
| 14 |
|
| 15 |
auto f1 = [](this auto&& self) { return self; }; |
| 16 |
auto fp1_value = static_cast<int(*)(int) >(&decltype(f1)::operator()); // { dg-error {invalid 'static_cast' from type} } |
| 17 |
auto fp1_lref = static_cast<int(*)(int&) >(&decltype(f1)::operator()); |
| 18 |
auto fp1_rref = static_cast<int(*)(int&&) >(&decltype(f1)::operator()); |
| 19 |
auto fp1_constlref = static_cast<int(*)(int const&) >(&decltype(f1)::operator()); |
| 20 |
auto fp1_constrref = static_cast<int(*)(int const&&)>(&decltype(f1)::operator()); |
| 21 |
} |
| 22 |
|
| 23 |
void test1() |
| 24 |
{ |
| 25 |
auto f0 = [](this auto self) { return self; }; |
| 26 |
int (*fp0_value)(int) = &decltype(f0)::operator(); |
| 27 |
int (*fp0_lref)(int&) = &decltype(f0)::operator(); |
| 28 |
int (*fp0_rref)(int&&) = &decltype(f0)::operator(); |
| 29 |
int (*fp0_constlref)(int const&) = &decltype(f0)::operator(); |
| 30 |
int (*fp0_constrref)(int const&&) = &decltype(f0)::operator(); |
| 31 |
|
| 32 |
auto f1 = [](this auto&& self) { return self; }; |
| 33 |
int (*fp1_value)(int) = &decltype(f1)::operator(); // { dg-error {no matches converting function} } |
| 34 |
int (*fp1_lref)(int&) = &decltype(f1)::operator(); |
| 35 |
int (*fp1_rref)(int&&) = &decltype(f1)::operator(); |
| 36 |
int (*fp1_constlref)(int const&) = &decltype(f1)::operator(); |
| 37 |
int (*fp1_constrref)(int const&&) = &decltype(f1)::operator(); |
| 38 |
} |
| 39 |
|