I have a static method my_method_1() in my_class, and I am trying to use it in a lambda:
static void my_method_1(el);
void my_class::my_method_2()
{
    std::for_each(my_list_.begin(), my_list_.end(),
        [](auto& element)
        {
            my_method_1(element);
        });
}
gcc6 gives me an error:
'this' was not captured for this lambda function
In gcc4, it compiles.
 
                        
Cannot reproduce.
According the error ("error: ‘this’ was not captured for this lambda function")
my_method_1()isn'tstatic.If
my_method_1()is a non-static method, you can use it inside a lambda capturingthisby value (that is like capturing the object by reference); something likeIf
my_method_1()is really astaticmethod, please prepare a minimal but complete example to reproduce your problem.