It makes sense to me.

Published May 23, 2005
Advertisement
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);    }}
Previous Entry Sorry
0 likes 7 comments

Comments

johnhattan
Template abuse makes my brain itch.
May 23, 2005 09:38 PM
Washu
Your brain is an itch.
May 23, 2005 09:46 PM
Saruman
omg :)
May 23, 2005 10:42 PM
superpig
It makes sense to me too.
May 24, 2005 03:34 AM
Drew_Benton
Too...much...knowledge...here...

Thanks Washu [smile] I just need to go and read all your stuff.
May 25, 2005 10:29 PM
paulecoyote
interesting
May 27, 2005 03:46 AM
Samith
Makes sense to me, too, I just wouldn't know what to do with it all.
July 10, 2005 04:31 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement