Compiler Error C3480
'var': a lambda capture variable must be from an enclosing function scope
The lambda capture variable is not from an enclosing function scope.
To correct this error
- Remove the variable from the capture list of the lambda expression.
Examples
The following example generates C3480 because the variable global
is not from an enclosing function scope:
// C3480a.cpp
int global = 0;
int main()
{
[&global] { global = 5; }(); // C3480
}
The following example resolves C3480 by removing the variable global
from the capture list of the lambda expression:
// C3480b.cpp
int global = 0;
int main()
{
[] { global = 5; }();
}
See also
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for