C++ template param deduction is not working -
i need override connection between boost::signals2::signal
, boost::function
. purpose i've created following template function:
template<typename t> void bind(boost::signals2::signal<t> &signal, boost::function<t> function) { // override code ... }
i want make use of bind
simple can be. i've read in posts on similar issues, template parameter should deduced function arguments. in case when there's no explicit parameter it's not working.
boost::signals2::signal<void ()> my_signal; bind<void ()>(my_signal, boost::bind(&a::func, this)); // works bind(my_signal, boost::bind(&a::func, this)); // error: no matching function call
am missing something? can there workaround avoid explicit template parameter?
the second argument type not std::function<t>
, bind type, compiler unable deduce t
second function parameter. need tell compiler "you ok not finding type t
in second function parameter". can done making second parameter non-deduced context.
template<typename t> void bind(boost::signals2::signal<t> &signal, typename std::common_type<boost::function<t>>::type function) { // override code ... }
Comments
Post a Comment