xref: /llvm-project/clang/test/SemaCXX/constexpr-explicit-object-lambda.cpp (revision bd77a26e9a15981114e9802d83047f42631125a2)
1 // RUN: %clang_cc1 -std=c++23 -verify %s
2 // expected-no-diagnostics
3 
4 struct S {
5   int i = 42;
f1S6   constexpr auto f1() {
7     return [this](this auto) {
8       return this->i;
9     }();
10   };
11 
f2S12   constexpr auto f2() {
13     return [this](this auto&&) {
14       return this->i;
15     }();
16   };
17 
f3S18   constexpr auto f3() {
19     return [i = this->i](this auto) {
20       return i;
21     }();
22   };
23 
f4S24   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);
35