C++ Expression Templates
By Angelika Langer and Klaus Kreft, March 01, 2003
Do you want high-performance, readable expressions? Expression templates do it all.
March 2003/C++ Expression Templates
Listing 11: Adding creator functions for each unary or binary expression
template <class ExprT>
UnaryExpr<ExprT,double(*)(double)>
sqrt(const ExprT& e)
{return UnaryExpr<ExprT,double(*)(double)>(e,::std::sqrt);}
template <class ExprT>
UnaryExpr<ExprT,double(*)(double)>
exp(const ExprT& e)
{ return UnaryExpr<ExprT,double(*)(double)>(e,::std::exp); }
...
End of Listing