llvm-project/clang/test/SemaCXX/cxx2a-lambda-equals-this.cpp
Faisal Vali 8194a3e975 [c++2a] Implement P0409R2 - Allow lambda capture [=,this] (by hamzasood)
This patch, by hamzasood, implements P0409R2, and allows [=, this] pre-C++2a as an extension (with appropriate warnings) for consistency.

https://reviews.llvm.org/D36572

Thanks Hamza!

llvm-svn: 311224
2017-08-19 03:43:07 +00:00

16 lines
403 B
C++

// RUN: %clang_cc1 -std=c++2a -verify %s
// expected-no-diagnostics
// This test does two things.
// Deleting the copy constructor ensures that an [=, this] capture doesn't copy the object.
// Accessing a member variable from the lambda ensures that the capture actually works.
class A {
A(const A &) = delete;
int i;
void func() {
auto L = [=, this]() -> int { return i; };
L();
}
};