aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp23/lambda-scope6.C
blob: 720c1ec6cba2be54afaf24d31ba0de5888a39cb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// P2036R3 - Change scope of lambda trailing-return-type
// PR c++/102610
// { dg-do compile { target c++23 } }

void
g ()
{
  /* It looks like this shouldn't work but [expr.prim.lambda.closure]/6
     says "Otherwise, it is a non-static member function or member function
     template that is declared const if and only if the lambda-expression's
     parameter-declaration-clause is not followed by mutable and the
     lambda-declarator does not contain an explicit object parameter."  */
  auto counter = [j=0](this auto const& self) -> decltype(j) {
      return j++;
  };

  auto counter2 = [j=0](this auto& self) -> decltype(j) {
      return j++;
  };
}