What's the correct way to have an anonymous local function object access an argument of the containing method? I.e., what's the correct way to do the following:
void A::foo(B& b)
{
struct {
void operator()() {b.bar();}
} func;
func();
}
NB: This example is contrived for simplicity: the actual use-case involves applying an anonymous local function object to each element in a container to have the element act on the argument of the containing method.