aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2009-04-27 12:30:42 +0000
committerMax Horn2009-04-27 12:30:42 +0000
commit462e3bd49da49efd2bbee611467e8940c6e41177 (patch)
treeb2680b2ba59ee96dacab1e7cabf0bb510806fd16
parent5881abb213449ad8ac169c4dea729b7e7bca535f (diff)
downloadscummvm-rg350-462e3bd49da49efd2bbee611467e8940c6e41177.tar.gz
scummvm-rg350-462e3bd49da49efd2bbee611467e8940c6e41177.tar.bz2
scummvm-rg350-462e3bd49da49efd2bbee611467e8940c6e41177.zip
COMMON: Added Functor2Fun; fixed some typos
svn-id: r40160
-rw-r--r--common/func.h26
1 files 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<void, Foo> myFunctor(&bar, &Foo::myFunc);
+ * Functor0Mem<void, Foo> myFunctor(&bar, &Foo::myFunc);
*
* Example usage:
*
@@ -439,7 +439,7 @@ struct Functor1 : public Common::UnaryFunction<Arg, Res> {
* Usage is like with Functor0Mem. The resulting functor object
* will take one parameter though.
*
- * @see Functor0Men
+ * @see Functor0Mem
*/
template<class Arg, class Res, class T>
class Functor1Mem : public Functor1<Arg, Res> {
@@ -471,11 +471,31 @@ struct Functor2 : public Common::BinaryFunction<Arg1, Arg2, Res> {
};
/**
+ * Functor object for a binary function.
+ *
+ * @see Functor2Mem
+ */
+template<class Arg1, class Arg2, class Res>
+class Functor2Fun : public Functor2<Arg1, Arg2, Res> {
+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 Arg1, class Arg2, class Res, class T>
class Functor2Mem : public Functor2<Arg1, Arg2, Res> {