
joel wrote:
Eric Niebler wrote:
I don't have a good solution at my fingertips or the time to come up with something really whiz-bang, but you can get part of the way with the proto::lazy transform. For instance, you can handle all binary expressions with:
bp::when< bp::nary_expr< bp::_, eval_xpr, eval_xpr > , bp::lazy< functor< bp::tag_of< bp::_ > >( eval_xpr(bp::_left) , eval_xpr(bp::_right) )> >
This uses proto::make to turn functor< bp::tag_of< bp::_ > > into, e.g., function< proto::tag::plus > and then uses proto::call to invoke it.
Hope that moves you in the right direction,
Aaaah bp::lazy ! I was indeed trying to find such thing like that.Maybe I can combine this with some fusion::fused or unfused somehow. I'll give this a try.
Also look into proto::functional::unpack_expr, which turns a Fusion
sequence into a proto expression node. For instance, you might turn an
N-ary expression into an (N+1)-ary expression representing a function
invocation like (untested) ...
when< nary_expr< _, vararg