
On 1/10/2011 10:00 AM, Hossein Haeri wrote:
Dear all,
In the Proto documentation, is there any reason why in all the specialisations of eval<Expr> for contexts, the first argument to their operator() is of type Expr& as opposed to const Expr&?
The docs don't make this very clear (and are in fact a little out of date) but this: const Expr & e = ...; Context ctx; proto::eval( e, ctx ); is essentially equivalent to: Context::eval< Expr const, Context >()( e, ctx ); -----------------^^^^^^^^^^ That is, proto::eval deduces the const-ness of the expression and uses that in the instantiation of the nested eval struct. For that reason, eval::operator() need only take the expression parameter by Expr &. The const-ness is baked into the "Expr" template parameter. Hope that makes sense. If not, just look at the implementation of proto::eval. It's a one-liner. -- Eric Niebler BoostPro Computing http://www.boostpro.com