Boost Users :
Subject: Re: [Boost-users] [Phoenix][v3] Argument/State dependent return type of actors?
From: Josef Weinbub (weinbub_at_[hidden])
Date: 2012-01-05 03:47:28
On 01/-10/-28163 08:59 PM, Thomas Heller wrote:
> Sorry I missed it, yes, the result_of protocol is used throughout the
not a problem, I figured it out, finally ;-)
thanks for coming back to me, though
> At the bottom of this page is a list of functions and proto transforms
> to access the environment inside the context. For every function,
> there exists a boost::phoenix::result_of::*name* metafunction, where
> *name* stands for thing you want to extract.
> Let's say you want to compute the type of the first passed parameter:
> // Extract the Environment, which is a fusion vector ...
> typename boost::phoenix::result_of::env<Context>::type
ya, this I know - works fine ;-)
> // ... and extract the first argument:
> typename boost::fusion::result_of::at_c<env_type, 1>::type
here is a problem: the environment is a phoenix::vector2 sequence, so
the sequence has two elements.
afaik, the first is the actor, and the second seems to be the argument
type. (as there is atm only one argument, it's a two-element vector ..)
however, in my case the environment type has a reference modifier
attached, so I first have to remove it, prior to accessing it
typedef typename boost::fusion::result_of::at_c<
typename boost::remove_reference<env_type>::type , 1
do you know where this reference modifier is coming from?
btw: for the sake of completeness, I figured out another way to access
by accessing the argument sequence of the environment, have a look at
// access the args_type member ..
// no free meta-function is used here, so apparently I exploit some
unintentional stuff ?!
// afaik, the args_type member type is nested in the basic_environment
coming from spirit/home/phoenix ..
typedef typename boost::remove_reference<env_type>::type::args_type
Arguments const& args = env.args();
// now I access the first argumet, which corresponds to the direct
approach via the access
// to the 1. element of the environment ..
typedef typename boost::fusion::result_of::value_at_c<Arguments,
Argument0 arg0 = boost::fusion::at_c<0>(args);
tbh I also like this approach, as it is straightforward: one extracts
the environment from the context, and
afterwards the argument sequence is extracted from the environment.
> Best regards,
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net