Hi
Recently I made myself familiar with Phoenix v3, more specifically with
actors.
I did a few test implementations, and I wondered if there is a
way to access the argument types (nested in the context's environment)
and/or the type of the state(s) (nested in the proto expression) for the
actor's result type declaration.
Have a look at the following actor dummy implementation, especially at the
line ''typedef int result_type;'': (for the sake of completeness, the
complete actor
implementation is provided)
------------------------------------------------------------
BOOST_PHOENIX_DEFINE_EXPRESSION(
(boost)(phoenix)(myactor)
, (boost::phoenix::meta_grammar)
)
struct myactor_eval {
// ------------------------
// the result type can not be made dependable from
// one of the actors argument types .. it is
//
typedef int result_type;
// ------------------------
template
result_type
operator()(StateExpr const& state_expr, Context & ctx) const {
return -1;
}
};
namespace boost { namespace phoenix {
template <>
struct default_actions::when< rule::myactor>
: boost::phoenix::call< ::myactor_eval> {};
template <typename T>
typename expression::myactor<T>::type const
inline myactor(T& t) {
return expression::myactor<T>::make(t);
}
}}
------------------------------------------------------------
As I already stated, I wonder if there is a way to have access to the
argument and state types for the result type, maybe as it was possible
in Phoenix v2 via a nested template struct which got the same template
parameters
as the functor, like the simple example in the following:
------------------------------------------------------------
struct myactor_eval {
template
struct result {
typedef typename result_of::env<Context>::type Environment;
typedef typename remove_reference<
Environment>::type::args_type Args;
typedef typename result_of::value_at_c<
Args, 0>::type Parameter;
// make the result type argument dependent!
typedef typename Parameter::value_type type;
}; ...
};
------------------------------------------------------------
I do hope that I haven't overlooked something in the docs, sorry if I did.
Thanks for your support!
Cheers, Josef Weinbub