|
Boost : |
Subject: Re: [boost] Case study: Boost.Local versus Boost.Phoenix
From: Anthony Williams (anthony.ajw_at_[hidden])
Date: 2011-02-04 13:03:35
Christian Holmquist <c.holmquist_at_[hidden]> 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
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk