From 462e3bd49da49efd2bbee611467e8940c6e41177 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 27 Apr 2009 12:30:42 +0000 Subject: COMMON: Added Functor2Fun; fixed some typos svn-id: r40160 --- common/func.h | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/common/func.h b/common/func.h index 6aa5b76ed4..dcad7ce6bf 100644 --- a/common/func.h +++ b/common/func.h @@ -372,7 +372,7 @@ struct Functor0 { * Example creation: * * Foo bar; - * Functor0Men myFunctor(&bar, &Foo::myFunc); + * Functor0Mem myFunctor(&bar, &Foo::myFunc); * * Example usage: * @@ -439,7 +439,7 @@ struct Functor1 : public Common::UnaryFunction { * Usage is like with Functor0Mem. The resulting functor object * will take one parameter though. * - * @see Functor0Men + * @see Functor0Mem */ template class Functor1Mem : public Functor1 { @@ -470,12 +470,32 @@ struct Functor2 : public Common::BinaryFunction { virtual Res operator()(Arg1, Arg2) const = 0; }; +/** + * Functor object for a binary function. + * + * @see Functor2Mem + */ +template +class Functor2Fun : public Functor2 { +public: + typedef Res (*FuncType)(Arg1, Arg2); + + Functor2Fun(const FuncType func) : _func(func) {} + + bool isValid() const { return _func != 0; } + Res operator()(Arg1 v1, Arg2 v2) const { + return (*_func)(v1, v2); + } +private: + const FuncType _func; +}; + /** * Functor object for a binary class member function. * Usage is like with Functor0Mem. The resulting functor object * will take two parameter though. * - * @see Functor0Men + * @see Functor0Mem */ template class Functor2Mem : public Functor2 { -- cgit v1.2.3