
Christian Holmquist <c.holmquist@gmail.com> writes:
I've made a habit (which have been widely adapted by others at my workplace) to make local lambdas like this:
void my_function() { foo_type foo; bar_type bar;
struct { foo_type &foo_; bar_type &bar_; void operator()(a_type a) const { foo_(a); bar_(a); } } lambda = { foo, bar} ;
for_each(as.begin(),as.end(),lambda);
}
I don't know if that's standard compliant, but works perfectly fine in MSVC.
It's not legal C++03, but is legal C++0x. Anthony -- Author of C++ Concurrency in Action http://www.stdthread.co.uk/book/ just::thread C++0x thread library http://www.stdthread.co.uk Just Software Solutions Ltd http://www.justsoftwaresolutions.co.uk 15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976