Boost logo

Boost :

From: Maurizio Vitale (maurizio.vitale_at_[hidden])
Date: 2007-07-17 08:48:04

bitten by this in the past. There's a proto::deep_copy function that
you can use for converting references to values.

On Jul 17, 2007, at 2:54 AM, dan marsden wrote:

> Hi
> I'm creating lambda expressions using proto, using the extension
> mechanism to add my own operator() so that I can do:
> (_0 += _1)(x,y)
> The operator() does all the transforming of the expression tree,
> and evaluates the result. The above works ok, its pretty similar to
> your calculator examples.
> If I want to do something like
> function<int(int&,int&)> f(_0 + _1); // Copy lambda expression into
> a Boost.Function func
> Now I've got problems because proto trees are built out of
> references (to temporaries). So func will blow up later when the
> temporaries are off the stack (actually the example I've tried
> starts evaluating junk values). I believe the above code will work
> today with BLL and Phoenix, as the temporaries are copied rather
> than handled as references.
> As I cannot interfere with the Boost.Function constructors, how can
> I transform my expression tree to change the refs to copies, whilst
> retaining the syntax above? Is there some way to tell proto to
> build trees with copies? Or have I missed something clever in proto
> again :) It might make a good Calc4 example as I imagine this is a
> common requirement.
> Cheers
> Dan
> ___________________________________________________________
> Yahoo! Mail is the world's favourite email. Don't settle for less,
> sign up for
> your free account today*http://
> _______________________________________________
> Unsubscribe & other changes:
> listinfo.cgi/boost

Boost list run by bdawes at, gregod at, cpdaniel at, john at