Compiler Error C3496
Visual Studio 2015
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at Compiler Error C3496.
this' is always captured by value: '&' ignored
You cannot capture the this pointer by reference.
To correct this error
- Capture the
thispointer by value.
The following example generates C3496 because a reference to the this pointer appears in the capture list of a lambda expression:
// C3496.cpp
// compile with: /c
class C
{
void f()
{
[&this] {}(); // C3496
}
};
Show: