The latest version of this topic can be found at Lambda Expression Syntax. Lambda ... C++ Lambda: Access static method in lambda leads to ... not captured for this lambda function) ... in lambda capture list inside a member function; Well talk about what that means soon. Caveat. The anonymous function is not supported by ... Lambda functions are function objects of ... mkAdder returns an anonymous function, which has captured If you are unfamiliar with the concept of the "this" pointer, it is a pointer to the object whose member function you are calling. test.cpp: In lambda function: test.cpp:44:21: error: 'this' was not captured for this lambda function (Interestingly, g++ 4.5 compiles the code fine). Try adding f to the capture list (change  to read [&f]). /home/marshall/code/chromium_git/chromium/src/tools/clang/plugins/FindBadConstructsConsumer.cpp: In lambda function: ... was not captured for this lambda function CPP-10180 Compile error "'this' was not captured for this lambda function" not detected Duplicates: CPP-3191 Relates to: CPP-8797 Subtask of: CPP-3191 Reproduce: Global variables, static members can be used but they are not captured. If a lambda expression (or an instantiation of a generic lambda's function call operator) ODR-uses this or any variable with automatic storage duration, it must be captured by the lambda expression. You use the f parameter in the lambda inside asort(), but you don't capture it. CPP-10180 Compile error "'this' was not captured for this lambda function" not detected Duplicates: CPP-3191 Relates to: CPP-8797 Subtask of: CPP-3191 Reproduce: If you have any opinions on this, please leave a comment! Here is an example that might help. Im not aware of any advantages of one over the other except that maybe reducing the scope the lambda function body has access to may be desirable. Bug 51494 - Legal program rejection - capturing "this" when using static method inside lambda Depending on how you work, using lambdas may make testing more difficult. If you have to use a lot of external variables inside the lambda, the capture list can become a bit long. It means you want the lambda to capture the "this" pointer. ... to the for_each function is a lambda. For example, What is a lambda (function)? ... a lambda's function call operator is ... see "Higher-Order Lambda Expressions" in Examples of Lambda Expressions. Is this a bug in g++ 4.6, or is it really necessary to capture the 'this' parameter to be able to call a static member function? [PATCH] [lambda] Extract lambda functions from semantics.c. As a matter of fact, there is no standard type for lambdas. ... C++ Lambda: Access static method in lambda leads to error 'this was not captured for this lambda function' ... in-lambda-leads-to-error-this-was-not-captured C++ 11 introduced lambda expression to allow us write an inline function which can be used for short snippets of code that are not going to be reuse and not worth naming. As a special bonus: If there are no captured variables, then there is an additional conversion operator that can convert the lambda to a pointer to a nonmember function. C++ Async Development (not only for) for C# Developers Part II: Lambda functions the most common pitfalls Home C++ lambdas require capturing 'this' to call static member function? Why does lambda need 'this' since 'a' is a static member function. One important thing to note is that a lambda is not a std::function. The latest version of this topic can be found at Lambda Expression Syntax. Lambdas didn't come to C++ as a specific-purpose feature (i.e., functional programming): the existing STL components, like the for_each algorithm, and its new ones like or , allow you to specify function arguments This is possible only in the case of no captured variables because captured variables would require an AnonymousClass$0 instance parameter, but there is ... not retain state within a scope, and function ... function is a lambda. The this pointer can only be captured by value, not by reference, and it is const qualified, if the method in which the lambda expression is used, is const qualified as well. Capturing this pointer inside lambda function will automatically capture all the member variables for this object inside lambda. It is true that a lambda can be assigned to a std::function, but that is not its native type. I don't see why it should be, I even qualified the call with B::. lambdas require capturing 'this' to call ... not captured for this lambda function Lambda Expressions in C++. ... 'this' was not captured for this lambda function. Dealing with multiple captures. Not doing so results in ... function is captured by other lambdas or local functions that are ... in lambda expressions.