|
Boost Users : |
Subject: Re: [Boost-users] [phoenix] A simple lambda func as boost::function
From: Joel de Guzman (joel_at_[hidden])
Date: 2009-12-14 18:59:46
Richard Vock wrote:
> Hi boost gurus,
>
> after some time and a lot of pain I somehow managed
> to work with boost.lambda in a way that actually
> outweighs the costs (code elegance versus time spent
> compiling it), but I miss some features (like local
> variables) I see in that cute phoenix documentation
> and a lot of mailing list threads which all seem
> to propose using phoenix rather than lambda (and it
> indeed looks a lot better).
>
> But whenever I try to use it, I somehow fail at the
> most simple tasks. Take for example this minimalistic
> code example here (note the use of #define USE_LAMBDA):
> http://pastebin.com/m3f590a01
>
> Both versions (with and without USE_LAMBDA defined) compile
> well on the most recent stable g++ compiler, but the
> phoenix version does not output anything. Not at all.
> Also note, that this exact lambda expression is mentioned
> here:
> http://tinyurl.com/ybmp2lw
> (well, without the << "\n" but that doesn't change the
> problem)
>
> Could someone please enlighten me by telling me what I have
> to do here? I should mention I am bound to boost::function,
> not some funky phoenix::actor derivations...
Try removing lambda:
doSth(cout << arg1 << "\n");
Also, endl works on phoenix:
doSth(cout << arg1 << std::endl);
Regards,
-- Joel de Guzman http://www.boostpro.com http://spirit.sf.net http://www.facebook.com/djowel Meet me at BoostCon http://www.boostcon.com/home http://www.facebook.com/boostcon
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net