On Wed, Apr 6, 2011 at 10:29 PM, Karsten Ahnert
> Is there a direct way to transform an expression tree into another one?
> For example, is it possible that every proto::plus< > node is
> transformed to it left child? I tried to solve this problem via protos
> build-in transforms without success. It seems that they are suited for
> evaluation of an existing tree, but I might be wrong.
I'm pretty sure they can do both. For your example, I think something
along the lines of this might work (untested):
struct LeftPlus :
boost::proto::nary_expr< boost::proto::_, boost::proto::vararg<LeftPlus> >
This should recurse through expressions and replace sequences of
pluses with the left-most terminal. You may need some other criteria
to end the recursion depending on your use case.
Disclaimer: I'm relatively new to proto myself, so the experts might
have better solutions!
proto mailing list