gcc/testsuite/g++.dg/cpp23/explicit-obj-lambda4.C
raw| 1 | // P0847R7 |
| 2 | // { dg-do run { target c++23 } } |
| 3 | |
| 4 | // calls to call operator of a lambda with captures with an implicit object argument |
| 5 | // that derives from the lambda closure object |
| 6 | |
| 7 | template<typename T> |
| 8 | struct S : T { |
| 9 | using T::operator(); |
| 10 | }; |
| 11 | |
| 12 | template<typename T> |
| 13 | S(T) -> S<T>; |
| 14 | |
| 15 | int main() |
| 16 | { |
| 17 | static constexpr int magic = 42; |
| 18 | int n = magic; |
| 19 | S s{[n](this auto&&){return n;}}; |
| 20 | if (s () != magic) |
| 21 | __builtin_abort (); |
| 22 | } |
| 23 |