
Hi Eric,
MyClass mc(_1 >> &f >> &g >> &h); mc.set_input(-61.1); cout << mc.value();//returns h(g(f(-61.1)))
Here is my solution:
template<typename Expr>
struct MyClass
{
MyClass(const Expr& e): formula_(e) {}
double calculate(double d) const
{return evaluate(formula_, d);}
private:
const Expr formula_;//***
};
#define DEFINE_MY_CLASS(name, exp) MyClass
I would suggest transforming the expression into a unary function object (see my article on cpp-next.com about function composition),
I do follow that series of yours and have to say it's superb! :) I don't see how that's connected though. So, if you think your suggested solution above would be better than that of mine, I'd be more than happy to see more explanation. Specifically, what are you exactly referring to when you use the term "expression" above? And, leave it if you'd think my solution is good enough... :D TIA, --Hossein