25 #include "common/scummsys.h" 42 template<
class Arg,
class Result>
44 typedef Arg ArgumenType;
45 typedef Result ResultType;
51 template<
class Arg1,
class Arg2,
class Result>
53 typedef Arg1 FirstArgumentType;
54 typedef Arg2 SecondArgumentType;
55 typedef Result ResultType;
63 bool operator()(
const T &x,
const T &y)
const {
return x == y; }
71 bool operator()(
const T &x,
const T &y)
const {
return x < y; }
79 bool operator()(
const T &x,
const T &y)
const {
return x > y; }
86 typename Op::FirstArgumentType _arg1;
88 Binder1st(
const Op &op,
typename Op::FirstArgumentType arg1) : _op(op), _arg1(arg1) {}
90 typename Op::ResultType operator()(
typename Op::SecondArgumentType v)
const {
108 typename Op::SecondArgumentType _arg2;
110 Binder2nd(
const Op &op,
typename Op::SecondArgumentType arg2) : _op(op), _arg2(arg2) {}
112 typename Op::ResultType operator()(
typename Op::FirstArgumentType v)
const {
113 return _op(v, _arg2);
126 template<
class Arg,
class Result>
129 Result (*_func)(Arg);
131 typedef Result (*FuncType)(Arg);
134 Result operator()(Arg v)
const {
139 template<
class Arg1,
class Arg2,
class Result>
142 Result (*_func)(Arg1, Arg2);
144 typedef Result (*FuncType)(Arg1, Arg2);
147 Result operator()(Arg1 v1, Arg2 v2)
const {
148 return _func(v1, v2);
155 template<
class Arg,
class Result>
163 template<
class Arg1,
class Arg2,
class Result>
168 template<
class Result,
class T>
171 Result (T::*_func)();
173 typedef Result (T::*FuncType)();
175 MemFunc0(
const FuncType &func) : _func(func) {}
176 Result operator()(T *v)
const {
177 return (v->*_func)();
181 template<
class Result,
class T>
184 Result (T::*_func)()
const;
186 typedef Result (T::*FuncType)()
const;
189 Result operator()(
const T *v)
const {
190 return (v->*_func)();
194 template<
class Result,
class Arg,
class T>
197 Result (T::*_func)(Arg);
199 typedef Result (T::*FuncType)(Arg);
201 MemFunc1(
const FuncType &func) : _func(func) {}
202 Result operator()(T *v1, Arg v2)
const {
203 return (v1->*_func)(v2);
207 template<
class Result,
class Arg,
class T>
210 Result (T::*_func)(Arg)
const;
212 typedef Result (T::*FuncType)(Arg)
const;
215 Result operator()(
const T *v1, Arg v2)
const {
216 return (v1->*_func)(v2);
225 template<
class Result,
class T>
235 template<
class Result,
class T>
246 template<
class Result,
class Arg,
class T>
257 template<
class Result,
class Arg,
class T>
262 template<
class Result,
class T>
265 Result (T::*_func)();
267 typedef Result (T::*FuncType)();
270 Result operator()(T &v)
const {
275 template<
class Result,
class T>
278 Result (T::*_func)()
const;
280 typedef Result (T::*FuncType)()
const;
283 Result operator()(
const T &v)
const {
288 template<
class Result,
class Arg,
class T>
291 Result (T::*_func)(Arg);
293 typedef Result (T::*FuncType)(Arg);
296 Result operator()(T &v1, Arg v2)
const {
297 return (v1.*_func)(v2);
301 template<
class Result,
class Arg,
class T>
304 Result (T::*_func)(Arg)
const;
306 typedef Result (T::*FuncType)(Arg)
const;
309 Result operator()(
const T &v1, Arg v2)
const {
310 return (v1.*_func)(v2);
321 template<
class Result,
class T>
332 template<
class Result,
class T>
344 template<
class Result,
class Arg,
class T>
356 template<
class Result,
class Arg,
class T>
372 virtual bool isValid()
const = 0;
373 virtual Res operator()()
const = 0;
388 template<
class Res,
class T>
391 typedef Res (T::*FuncType)();
393 Functor0Mem(T *t,
const FuncType &func) : _t(t), _func(func) {}
395 bool isValid()
const {
return _func != 0 && _t != 0; }
396 Res operator()()
const {
397 return (_t->*_func)();
401 const FuncType _func;
436 template<
class Arg,
class Res>
440 virtual bool isValid()
const = 0;
441 virtual Res operator()(Arg)
const = 0;
451 template<
class Arg,
class Res,
class T>
454 typedef Res (T::*FuncType)(Arg);
456 Functor1Mem(T *t,
const FuncType &func) : _t(t), _func(func) {}
458 bool isValid()
const {
return _func != 0 && _t != 0; }
459 Res operator()(Arg v1)
const {
460 return (_t->*_func)(v1);
464 const FuncType _func;
472 template<
class Arg1,
class Arg2,
class Res>
476 virtual bool isValid()
const = 0;
477 virtual Res operator()(Arg1, Arg2)
const = 0;
485 template<
class Arg1,
class Arg2,
class Res>
488 typedef Res (*FuncType)(Arg1, Arg2);
492 bool isValid()
const {
return _func != 0; }
493 Res operator()(Arg1 v1, Arg2 v2)
const {
494 return (*_func)(v1, v2);
497 const FuncType _func;
507 template<
class Arg1,
class Arg2,
class Res,
class T>
510 typedef Res (T::*FuncType)(Arg1, Arg2);
512 Functor2Mem(T *t,
const FuncType &func) : _t(t), _func(func) {}
514 bool isValid()
const {
return _func != 0 && _t != 0; }
515 Res operator()(Arg1 v1, Arg2 v2)
const {
516 return (_t->*_func)(v1, v2);
520 const FuncType _func;
527 template<
typename T>
struct Hash;
530 #define GENERATE_TRIVIAL_HASH_FUNCTOR(T) \ 531 template<> struct Hash<T> : public UnaryFunction<T, uint> { \ 532 uint operator()(T val) const { return (uint)val; } \ 535 GENERATE_TRIVIAL_HASH_FUNCTOR(
bool);
536 GENERATE_TRIVIAL_HASH_FUNCTOR(
char);
537 GENERATE_TRIVIAL_HASH_FUNCTOR(
signed char);
538 GENERATE_TRIVIAL_HASH_FUNCTOR(
unsigned char);
539 GENERATE_TRIVIAL_HASH_FUNCTOR(
short);
540 GENERATE_TRIVIAL_HASH_FUNCTOR(
int);
541 GENERATE_TRIVIAL_HASH_FUNCTOR(
long);
542 GENERATE_TRIVIAL_HASH_FUNCTOR(
unsigned short);
543 GENERATE_TRIVIAL_HASH_FUNCTOR(
unsigned int);
544 GENERATE_TRIVIAL_HASH_FUNCTOR(
unsigned long);
546 #undef GENERATE_TRIVIAL_HASH_FUNCTOR MemFuncRef0< Result, T > mem_fun_ref(Result(T::*f)())
Definition: func.h:322
ConstMemFuncRef0< Result, T > mem_fun_Ref(Result(T::*f)() const)
Definition: func.h:333
PointerToUnaryFunc< Arg, Result > ptr_fun(Result(*func)(Arg))
Definition: func.h:156
MemFunc0< Result, T > mem_fun(Result(T::*f)())
Definition: func.h:226
Definition: algorithm.h:29
Binder2nd< Op > bind2nd(const Op &op, typename Op::SecondArgumentType t)
Definition: func.h:122
Binder1st< Op > bind1st(const Op &op, typename Op::FirstArgumentType t)
Definition: func.h:100