#include #include #include #include #include #include struct void_t{}; typedef std::string method_params; typedef boost::function method_functor; template struct functor { functor( Functor f, const char* name ) :m_func(f){} void operator()( const std::string& params, std::string& rtn ) { method_params p; m_func(p); } Functor m_func; }; class Private { public: typedef boost::function method; struct working_functor { working_functor(Private* cp):conp(cp){} Private* conp; void_t operator()( const method_params& p )const { return conp->method_name(p); } }; void test() { add_method_handler( "crashing_method", functor ( boost::bind( &Private::method_name, this, _1 ), "crashing_method" ) ); /* add_method_handler( "working_method", functor ( working_functor(this), "working_method" ) ); */ std::string result; methods["crashing_method"]( "hello_world",result ); // methods["working_method"]( "hello_world",result ); } void_t method_name( const method_params& p ) { std::cerr<<"methods.size: " < methods; }; int main( int argc, char** argv ) { Private p; p.test(); return 0; }