$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [Boost-users] [proto] declaring result type for callable contexts
From: Eric Niebler (eric_at_[hidden])
Date: 2009-06-05 14:58:07
Maurizio Vitale wrote:
> Eric,
>   
>   It seems like result types must be defined inside a struct eval, but
>   examples in the documentation show the form commented out below.
> 
>   Is this a recent change?
> 
>   Also, in absence of a result_type declaration inside struct eval {...}
>   the type defaults to int. Would it be possible to make it void or
>   some_ugly_looking_type_that_tell_me_i_is_all_wrong?
>   int might happen to be what the user wants, until he decide to change
>   it and hides the problem.
> 
>   template<typename Expr>
>   struct my_context : proto::callable_context<const my_context<Expr> > {
>     struct eval {typedef double result_type;};
> 
>     // doesn't work (anymore?)
>     //typedef double result_type;
>   };
There have been no recent changes in this area, though I have been 
reorganizing some code. The Context concept (ugh, not defined in the 
reference section, sorry) requires a nested eval struct template with a 
nested result_type typedef. Users can define a context that satisfies 
that requirement by inheriting from callable_context, which defines the 
nested eval<> struct for you, and is implemented in terms of member 
function overloads within the derived context type. That turns out to be 
a lot easier in most situations.
In short, if you're using callable_context, don't define nested eval<> 
structs. If you have some code that recently stopped working, you should 
post it so I can see that the problem is.
-- Eric Niebler BoostPro Computing http://www.boostpro.com