[Scummvm-cvs-logs] SF.net SVN: scummvm:[40160] scummvm/trunk/common/func.h

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Mon Apr 27 14:30:43 CEST 2009


Revision: 40160
          http://scummvm.svn.sourceforge.net/scummvm/?rev=40160&view=rev
Author:   fingolfin
Date:     2009-04-27 12:30:42 +0000 (Mon, 27 Apr 2009)

Log Message:
-----------
COMMON: Added Functor2Fun; fixed some typos

Modified Paths:
--------------
    scummvm/trunk/common/func.h

Modified: scummvm/trunk/common/func.h
===================================================================
--- scummvm/trunk/common/func.h	2009-04-27 12:29:51 UTC (rev 40159)
+++ scummvm/trunk/common/func.h	2009-04-27 12:30:42 UTC (rev 40160)
@@ -372,7 +372,7 @@
  * Example creation:
  *
  * Foo bar;
- * Functor0Men<void, Foo> myFunctor(&bar, &Foo::myFunc);
+ * Functor0Mem<void, Foo> myFunctor(&bar, &Foo::myFunc);
  *
  * Example usage:
  *
@@ -439,7 +439,7 @@
  * 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 @@
 };
 
 /**
+ * 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> {


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list