Re: [boost] [Proto] Copying expressions

Eric Niebler wrote:
Dan, this is a job for a custom generator. (Thanks, I haven't had need of one until now! This'll make a great example.) You're already using a generator to wrap your expressions. But you also need a deep_copy-ing generator. Here's the basic idea ...
<snip really useful example> Thanks, that looks like exactly what I was looking for. Glad to provide a handy example problem for the customer generators!
Of course, calling deep_copy() in the generator is sub-optimal. Every part of the tree has been deep_copied already except the top-most node. When I find time, I'll write a by_value_generator which makes sure everything in the tree is held by value.
Cool, I'll keep an eye out for by_value_generator.
(I'm using the BOOST_PROTO_EXTENDS macros here instead of proto::extends<> so that _1 can be statically initialized. You may want to do something similar, if you aren't already.)
I've not been using these yet, although I had encountered the static init issues. I'll switch to using the macros as well, thanks for pointing them out. Cheers Dan ___________________________________________________________ Yahoo! Answers - Got a question? Someone out there knows the answer. Try it now. http://uk.answers.yahoo.com/

dan marsden wrote:
Eric Niebler wrote:
Of course, calling deep_copy() in the generator is sub-optimal. Every part of the tree has been deep_copied already except the top-most node. When I find time, I'll write a by_value_generator which makes sure everything in the tree is held by value.
Cool, I'll keep an eye out for by_value_generator.
OK, by_value_generator is implemented now. Usage is: template<class Expr> struct my_expr; struct my_domain : domain<by_value_generator<generator<my_expr> > > {}; That's two sequenced generators. The first makes sure the child nodes are held by value, then forwards the result to the second, which wraps the new node in my_expr<>. The second generator is optional. -- Eric Niebler Boost Consulting www.boost-consulting.com The Astoria Seminar ==> http://www.astoriaseminar.com
participants (2)
-
dan marsden
-
Eric Niebler