#ifndef _fadapter_h_ #define _fadapter_h_ #include // used as adaptor's return/argument type, // to allow binders/composers usage struct __void_tag {}; #if !defined (STLPORT) || defined (_STLP_USE_NAMESPACES) using std::unary_function; #endif template class pointer_to_void_function { protected: Result (*ptr)(); public: explicit pointer_to_void_function(Result (*x)()) : ptr(x) {} Result operator()() const { return ptr(); } Result operator()(__void_tag) const { return ptr(); } }; // to feed composers template struct projectvoid : public unary_function { __void_tag operator()(const Arg1& x) const { return __void_tag(); } }; #if !defined (_STLP_MEMBER_POINTER_PARAM_BUG) template pointer_to_void_function ptr_fun(Result (*x)()) { return pointer_to_void_function(x); } // alternate name template pointer_to_void_function ptr_gen(Result (*x)()) { return pointer_to_void_function(x); } #endif /* !defined (_STLP_MEMBER_POINTER_PARAM_BUG) */ template class pointer_to_unary_procedure /* :public unary_function */ { protected: typedef void (*fun_type)(Arg); fun_type ptr; public: typedef Arg argument_type; pointer_to_unary_procedure() {} pointer_to_unary_procedure(fun_type x) : ptr(x) {} void operator() (Arg x) const { ptr(x); } }; template inline pointer_to_unary_procedure ptr_proc(void (*x)(Arg)) { return pointer_to_unary_procedure(x); } template class pointer_to_binary_procedure /* : public unary_function */ { protected: typedef void (*fun_type)(Arg1, Arg2); fun_type ptr; public: typedef Arg1 first_argument_type; typedef Arg2 second_argument_type; pointer_to_binary_procedure() {} pointer_to_binary_procedure(fun_type x) : ptr(x) {} void operator() (Arg1 x, Arg2 y) const { ptr(x, y); } }; template inline pointer_to_binary_procedure ptr_proc(void (*x)(Arg1, Arg2)) { return pointer_to_binary_procedure(x); } #endif