C++ Boost::bind: a pointer to a bound function may only be used to call the function -
i like
template<typename instancetype> void add_test(void (instancetype::* test_method )(void*), std::tr1::shared_ptr<instancetype> user_test_case) { boost::function<void ()> op; op = boost::bind<instancetype>(test_method, *user_test_case); but says:
1>d:\boost\boost/bind/mem_fn.hpp(359): error: pointer bound function may used call function 1> return (t.*f_); what wrong here?
- the 1st template argument of
bindreturn type. so, shouldvoid. or omit it. boost::functionsignature doesn't match 1 of bound function. makefunction<void(void *)>.- the functor create should accept 1 argument, provide appropriate argument placeholder.
- finally, can bind
shared_ptr, directly.
the bottom line: boost::function<void (void *)> op = boost::bind(test_method, user_test_case, _1);
Comments
Post a Comment