Code:class foo { int wesult; int result; template<class Pred> void call(Pred pred) { Pred(); } void test() { call([&](){ wesult=1; result=1; }); }; };
In the lamda function, I am apparently allowed to access/change a variable named wesult, but when I have a variable named result, I get a weird error:
This is with VS2010.Code:1>c:\test\test.cpp(19): error C2326: 'void `anonymous-namespace'::<lambda0>::operator ()(void) const' : function cannot access 'foo::result' 1>c:\test\test.cpp(19): error C2166: l-value specifies const object
Is 'result' a reserved keyword when used in combination with lambda's ? or is this some weird error ?
If I remove/comment out the result=1; then it compiles and runs normally.
Can anyone give this a try in VS2012 ?




Reply With Quote