
(Sorry for the delay, I'm just back from a week-long vacation.) Maurizio Vitale wrote:
On Jun 1, 2007, at 10:36 AM, Eric Niebler wrote:
Only context types derived from callable_context get unpacked nodes like that. If you don't inherit from callable_context, you'll get the whole node without any modification. The interface is a bit different, though. You'll need something like:
struct my_context { template<typename Expr> struct eval { typedef ... result_type; result_type operator()(Expr &expr, my_context &ctx) const { return ...; } }; };
If you want to handle binary nodes specially, you would define the eval member template as:
template<typename Expr, long Arity = Expr::arity::value> struct eval
and then partially specialize for binary nodes:
template<typename Expr> struct eval<Expr, 2>
Eric, just for my understanding, your suggestion is also the only way to proceed when the result type depends on Expr, right?
Not so. If your context type inherits from callable_context, you can define a nested result class template for calculating the return type. In this way, the return type can be made to depend on the expression type. HTH, -- Eric Niebler Boost Consulting www.boost-consulting.com The Astoria Seminar ==> http://www.astoriaseminar.com