00001 #ifndef _fadapter_h_
00002 #define _fadapter_h_
00003
00004 #include <functional>
00005
00006
00007
00008 struct __void_tag {};
00009
00010 # if !defined (STLPORT) || defined (__STL_USE_NAMESPACES)
00011 using std::unary_function;
00012 # endif
00013
00014 template <class Result>
00015 class pointer_to_void_function {
00016 protected:
00017 Result (*ptr)();
00018 public:
00019 explicit pointer_to_void_function(Result (*x)()) : ptr(x) {}
00020 Result operator()() const { return ptr(); }
00021 Result operator()(__void_tag) const { return ptr(); }
00022 };
00023
00024
00025 template <class Arg1>
00026 struct projectvoid :
00027 public unary_function<Arg1,__void_tag> {
00028 __void_tag operator()(const Arg1& x) const { return __void_tag(); }
00029 };
00030
00031 # if !defined (_STLP_MEMBER_POINTER_PARAM_BUG)
00032
00033 template <class Result>
00034 pointer_to_void_function<Result> ptr_fun(Result (*x)()) {
00035 return pointer_to_void_function<Result>(x);
00036 }
00037
00038
00039 template <class Result>
00040 pointer_to_void_function<Result> ptr_gen(Result (*x)()) {
00041 return pointer_to_void_function<Result>(x);
00042 }
00043
00044 # endif
00045
00046
00047 template <class Arg>
00048 class pointer_to_unary_procedure {
00049 protected:
00050 typedef void (*fun_type)(Arg);
00051 fun_type ptr;
00052 public:
00053 typedef Arg argument_type;
00054 pointer_to_unary_procedure() {}
00055 pointer_to_unary_procedure(fun_type x) : ptr(x) {}
00056 void operator() (Arg x) const { ptr(x); }
00057 };
00058 template <class Arg>
00059 inline pointer_to_unary_procedure<Arg> ptr_proc(void (*x)(Arg)) {
00060 return pointer_to_unary_procedure<Arg>(x);
00061 }
00062
00063 template <class Arg1, class Arg2>
00064 class pointer_to_binary_procedure {
00065 protected:
00066 typedef void (*fun_type)(Arg1, Arg2);
00067 fun_type ptr;
00068 public:
00069 typedef Arg1 first_argument_type;
00070 typedef Arg2 second_argument_type;
00071 pointer_to_binary_procedure() {}
00072 pointer_to_binary_procedure(fun_type x) : ptr(x) {}
00073 void operator() (Arg1 x, Arg2 y) const { ptr(x, y); }
00074 };
00075 template <class Arg1, class Arg2>
00076 inline pointer_to_binary_procedure<Arg1, Arg2> ptr_proc(void (*x)(Arg1, Arg2)) {
00077 return pointer_to_binary_procedure<Arg1, Arg2>(x);
00078 }
00079
00080 #endif
00081