|
Boost Users : |
Subject: [Boost-users] [phoenix] Extending actors
From: paul Fultz (pfultz2_at_[hidden])
Date: 2012-02-22 19:57:11
Hi all,
I am wanting to extend actors to access a member variable from the class. In the
examples they show extending an acotr by using a lazy function to call the function.
I was thinking I could use a lazy function to access the member, something like this:
template <typename Expr>
struct point_actor
: actor<Expr>
{
typedef actor<Expr> base_type;
typedef point_actor<Expr> that_type;
point_actor( base_type const& base )
: base_type( base ) {}
typename expression::function<x_impl, that_type>::type x;
typename expression::function<y_impl, that_type>::type y;
};
Where x_impl and y_impl are lazy functions that access the x and y variable.
Would this work as member variables, rather than member functions? Also,
why wouldnt the second parameter to expression::function take just actor
instead of just point_actor<Expr>? Does that make sense? The reason I ask is I would like to
control the actor that is returned and do something like this(using the above actor):
template <typename Expr>
struct rect_actor
: actor<Expr>
{
typedef actor<Expr> base_type;
typedef rect_actor<Expr> that_type;
rect_actor( base_type const& base )
: base_type( base ) {}
typename expression::function<top_impl, point_actor >::type top;
typename expression::function<bottom_impl, point_actor >::type bottom;
};
expression::terminal<phoenix::argument<1>, rect_actor > arg1;
(cout << arg1.top.x)(my_rect());
Does that make sense? I can't seem to find any reference on the predefined
expressions, and I also can't find the header file for expression::function.
Finally, the is_actor trait doesn't seem work for extended actors.Is there a
workaround for that?
Thanks,
Paul
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