namespace sktl { template struct Functor { virtual T operator()(T const& val) const { return T(); } typedef T value_type; typedef Functor this_type; }; template struct Constant : Functor { Constant(T const& val) : val_(val) {} T operator()(T const& val) const { return val_; } typedef Constant this_type; private: T val_; }; template struct Variable : Functor { T operator()(T const& val) const { return val; } typedef Variable this_type; }; template struct MulOp : Functor { MulOp(L l, R r) : l_(l), r_(r) {} T operator()(T const& val) const { return l_(val) * r_(val); } typedef MulOp this_type; private: L l_; R r_; }; template struct DivOp : Functor { DivOp(L l, R r) : l_(l), r_(r) {} T operator()(T const& val) const { return l_(val) / r_(val); } typedef DivOp this_type; private: L l_; R r_; }; template struct AddOp : Functor { AddOp(L l, R r) : l_(l), r_(r) {} T operator()(T const& val) const { return l_(val) + r_(val); } typedef AddOp this_type; private: L l_; R r_; }; template struct SubOp : Functor { SubOp(L l, R r) : l_(l), r_(r) {} T operator()(T const& val) const { return l_(val) - r_(val); } typedef SubOp this_type; private: L l_; R r_; }; template struct PowOp : Functor { PowOp(L l, R r) : l_(l), r_(r) {} T operator()(T const& val) const { return std::pow(l_(val), r_(val)); } typedef PowOp this_type; private: L l_; R r_; }; template struct SqrtOp : Functor { SqrtOp(L l) : l_(l) {} T operator()(T const& val) const { return std::sqrt(l_(val)); } typedef SqrtOp this_type; private: L l_; }; template struct SinOp : Functor { SinOp(L l) : l_(l) {} T operator()(T const& val) const { return std::sin(l_(val)); } typedef SinOp this_type; private: L l_; }; template struct CosOp : Functor { CosOp(L l) : l_(l) {} T operator()(T const& val) const { return std::cos(l_(val)); } typedef CosOp this_type; private: L l_; }; template struct TanOp : Functor { TanOp(L l) : l_(l) {} T operator()(T const& val) const { return std::tan(l_(val)); } typedef TanOp this_type; private: L l_; }; template struct SinhOp : Functor { SinhOp(L l) : l_(l) {} T operator()(T const& val) const { return std::sinh(l_(val)); } typedef SinhOp this_type; private: L l_; }; template struct CoshOp : Functor { CoshOp(L l) : l_(l) {} T operator()(T const& val) const { return std::cosh(l_(val)); } typedef CoshOp this_type; private: L l_; }; template struct TanhOp : Functor { TanhOp(L l) : l_(l) {} T operator()(T const& val) const { return std::tanh(l_(val)); } typedef TanhOp this_type; private: L l_; }; template struct ArcSinOp : Functor { ArcSinOp(L l) : l_(l) {} T operator()(T const& val) const { return std::asin(l_(val)); } typedef ArcSinOp this_type; private: L l_; }; template struct ArcCosOp : Functor { ArcCosOp(L l) : l_(l) {} T operator()(T const& val) const { return std::acos(l_(val)); } typedef ArcCosOp this_type; private: L l_; }; template struct ArcTanOp : Functor { ArcTanOp(L l) : l_(l) {} T operator()(T const& val) const { return std::atan(l_(val)); } typedef ArcTanOp this_type; private: L l_; }; template SqrtOp sqrt(L const& l) { typedef SqrtOp Op; return Op(l); } template SinOp sin(L const& l) { typedef SinOp Op; return Op(l); } template CosOp cos(L const& l) { typedef CosOp Op; return Op(l); } template TanOp tan(L const& l) { typedef TanOp Op; return Op(l); } template SinhOp sinh(L const& l) { typedef SinhOp Op; return Op(l); } template CoshOp cosh(L const& l) { typedef CoshOp Op; return Op(l); } template TanhOp tanh(L const& l) { typedef TanhOp Op; return Op(l); } template ArcSinOp asin(L const& l) { typedef ArcSinOp Op; return Op(l); } template ArcSinOp acos(L const& l) { typedef ArcSinOp Op; return Op(l); } template ArcSinOp atan(L const& l) { typedef ArcSinOp Op; return Op(l); } template MulOp operator*(R const& r, L const& l) { typedef MulOp Op; return Op(r, l); } template DivOp operator/(R const& r, L const& l) { typedef DivOp Op; return Op(r, l); } template AddOp operator+(R const& r, L const& l) { typedef AddOp Op; return Op(r, l); } template SubOp operator-(R const& r, L const& l) { typedef SubOp Op; return Op(r, l); } template PowOp operator^(R const& r, L const& l) { typedef PowOp Op; return Op(r, l); }}
Honestly, it does
Previous Entry
Sorry
Next Entry
Dynamic Link Libraries
Advertisement
Latest Entries
C++ Quiz #4
1349 views
C++ Quiz #4
2694 views
C++ Quiz #3
1214 views
C++ Quiz #3
1874 views
C++ Quiz #2
1203 views
Advertisement