[Proto] Non-const First Argument for Nested eval<>'s operator() ()
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&? TIA, --Hossein
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
Hi Eric,
The docs don't make this very clear (and are in fact a little out of date) but <snip>
I'd suggest adding the explanation at the right corner(s) then.
Hope that makes sense.
Yes, it does. Thanks. :) --Hossein
participants (2)
-
Eric Niebler
-
Hossein Haeri