The examples I have found that capture this
in a lambda use it explicitly; e.g.:
capturecomplete = [this](){this->calstage1done();};
But it seems it is also possible to use it implicitly; e.g.:
capturecomplete = [this](){calstage1done();};
I tested this in g++, and it compiled.
Is this standard C++? (and if so, which version), or is it some form of extension?
this->
explicitly, which is to ensure that explicitly captured values are used explicitly. Note that[](){ calstage1done(); }
would not be legal, becausethis
wouldn't be captured; but when capturingthis
explicitly, it's surprising for the function body to appear at a glance not to actually use the captured value:[this](){ calstage1done(); }
. – Keimthis
and using it in a lambda which might also be a reason to use it explicitly – Genitourinary