I wanted to write a lambda that returns itself, so I could call it multiple times on the spot. But it looks like inside of a lambda this
refers not to the lambda but to the surrounding object's this
, if the lambda is defines inside a member function.
Here's an example:
#include <iostream>
int main(int argc, char* argv[]) {
int a = 5;
[&](int b) {
std::cout << (a + b) << std::endl;
return *this;
}(4)(6);
}
Is there a way to do something comparable?