It seems that I can define lambda expressions that capture this
in the class area. As far as I read the N4640 working draft today, I could not find a suggestion that allowed behavior. I think I'm missing something ...
Here is an example:
#include <iostream>
#include <functional>
struct foo {
std::function<void()> f1 = [this]{ ++i; };
int i = 0;
};
int main() {
foo a;
foo const& cref = a;
cref.f1();
std::cout << a.i << std::endl;
}
Launch a demo. (g ++ -std = C ++ 11 pedantic)
https://wandbox.org/permlink/HPzaOxbBkOQOmuS6
Update
@Brian @cpplerner, , . " this
" - ".
, this
. .
, this
.
, N4640 9.2.2.1 [class.this]. , , . - 9.2.2/3 9.2.2/4.
, .
?