
Hello all, Can anyone try the following code on a MSVC compiler with lambdas (MSVC10?)? #include <vector> struct person {}; struct world { void add_person(person const& a_person) { bool commit = false; persons_.push_back(a_person); auto scope_exit = [&commit, &persons_]() mutable -> void { if(!commit) persons_.pop_back(); }; commit = true; scope_exit(); } private: std::vector<person> persons_; }; int main() { world w; person p; w.add_person(p); return 0; } This code compiles on GCC 4.5.3 with C++0x extensions (including lambdas) but based on some errors I'm seeing in trunk's ScopeExit regressions tests, I'm guessing it will fail using MSVC lambdas with errors similar to the followings: error C3480: 'world::persons_': a lambda capture variable must be from an enclosing function scope warning C4573: the usage of 'world::persons_' requires the compiler to capture 'this' but the current default capture mode does not allow it Unfortunately, I don't have a MSVC compiler with lambdas so thank you very much for trying my code! --Lorenzo -- View this message in context: http://boost.2283326.n4.nabble.com/boost-scope-exit-can-MSVC-lambdas-capture... Sent from the Boost - Dev mailing list archive at Nabble.com.