Debian Codegraph @

clang/test/SemaCXX/constexpr-explicit-object-lambda.cpp

raw
1 // RUN: %clang_cc1 -std=c++23 -verify %s
2 // expected-no-diagnostics
3
4 struct S {
5 int i = 42;
6 constexpr auto f1() {
7 return [this](this auto) {
8 return this->i;
9 }();
10 };
11
12 constexpr auto f2() {
13 return [this](this auto&&) {
14 return this->i;
15 }();
16 };
17
18 constexpr auto f3() {
19 return [i = this->i](this auto) {
20 return i;
21 }();
22 };
23
24 constexpr auto f4() {
25 return [i = this->i](this auto&&) {
26 return i;
27 }();
28 };
29 };
30
31 static_assert(S().f1() == 42);
32 static_assert(S().f2() == 42);
33 static_assert(S().f3() == 42);
34 static_assert(S().f4() == 42);