Jump to content
  • Advertisement
  • entries
    146
  • comments
    436
  • views
    198532

It makes sense to me.

Sign in to follow this  
Washu

321 views

Honestly, it does


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);
}
}
Sign in to follow this  


7 Comments


Recommended Comments

Too...much...knowledge...here...

Thanks Washu [smile] I just need to go and read all your stuff.

Share this comment


Link to comment
Makes sense to me, too, I just wouldn't know what to do with it all.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!