aboutsummaryrefslogtreecommitdiff
path: root/clang/test/SemaCXX/constexpr-explicit-object-lambda.cpp
blob: 4e8e94d428d071f8a738bbb352b4592ea67eeff3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// RUN: %clang_cc1 -std=c++23 -verify %s
// expected-no-diagnostics

struct S {
  int i = 42;
  constexpr auto f1() {
    return [this](this auto) {
      return this->i;
    }();
  };

  constexpr auto f2() {
    return [this](this auto&&) {
      return this->i;
    }();
  };

  constexpr auto f3() {
    return [i = this->i](this auto) {
      return i;
    }();
  };

  constexpr auto f4() {
    return [i = this->i](this auto&&) {
      return i;
    }();
  };
};

static_assert(S().f1() == 42);
static_assert(S().f2() == 42);
static_assert(S().f3() == 42);
static_assert(S().f4() == 42);