I am trying to evaluate a proto expression tree with a custom defined context. I have a struct exp_tag {}
using which a create a terminal
template <typename T>
inline typename proto::result_of::make_expr<exp_tag, T const &>::type
exp_t(T const &t) {
return proto::make_expr<exp_tag>(boost::cref(t));
}
I create the expression tree as follows :
exp_t(x)
And the tree looks like this
7exp_tag(
terminal(6tensorILm0EE)
)
In my context I evaluate the tree using function overloads like this :
template<typename A, typename B>
float operator()(proto::tag::plus, A& a, B& b) const {
auto va = proto::eval(a, *this);
auto vb = proto::eval(b, *this);
return va + vb;
}
When I attempt to do this for my exp_t
by replacing proto::tag::plus
with exp_tag
my code doesn't compile.
My guess is that since exp_t
is an expression because of proto::make_exr<exp_tag>
I can't treat it as a proto::tag
but I can't figure out how to do this.
What should I replace proto::tag::plus
with in order to evaluate exp_t
through the context?