On 01/-10/-28163 08:59 PM, Thomas Heller wrote:
Sorry I missed it, yes, the result_of protocol is used throughout the library.
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 ... typedef typename boost::phoenix::result_of::env<Context>::type env_type;
ya, this I know - works fine ;-)
// ... and extract the first argument: typedef typename boost::fusion::result_of::at_c<env_type, 1>::type arg_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 via fusion::at_c<>: typedef typename boost::fusion::result_of::at_c< typename boost::remove_reference<env_type>::type , 1
::type arg0;
do you know where this reference modifier is coming from? ------ btw: for the sake of completeness, I figured out another way to access the arguments, by accessing the argument sequence of the environment, have a look at the following: // 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; 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, 0>::type Argument0; 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, Thomas
thanks! cheers, josef