Boost logo

Boost Users :

Subject: Re: [Boost-users] [Phoenix][v3] Argument/State dependent return type of actors?
From: Josef Weinbub (weinbub_at_[hidden])
Date: 2012-01-03 03:17:37


On 01/-10/-28163 08:59 PM, Josef Weinbub wrote:
> 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.
>
....

Hi again!

Indeed I have overlooked something, being 'result_of' ... as provided by
the Boost Utility library and adopted
by the C++11 standard. Sorry for that, should have known ..

In case someone else wonders how to approach my problem, checkout the
Boost.Utility::result_of documentation:
http://www.boost.org/doc/libs/1_48_0/libs/utility/utility.htm#result_of

One has to nest a result struct with the functors parameter types in the
Boost.Phoenix actor's evaluation functor.
For the sake of completeness, in the following my previous evaluation
functor is depicted again, but instead
of the static "typedef int result_type; " we now use the nested result
struct:

struct myactor_eval {

    template<class> struct result;

    template<class F, typename StateExpr, typename Context>
    struct result<F(StateExpr, Context)>
    {
        // here we can relate the return type both to the state type
        // and to the functor's argument types ...
        typedef ..... type;
    };

    template <typename StateExpr, typename Context>
    typename myactor_eval::result< myactor_eval(StateExpr, Context) >::type
    operator()(StateExpr const& state_expr, Context & ctx) const {
       return ...;
    }
};

Best, Josef

PS: Thank you, Joel, for noticing my post and forwarding it to Thomas -
much appreciated!



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