Template argument deduction fails
Hi,
I have this call for a Subscriber:
ros::Subscriber sub = handle.subscribe<std_msgs::Bool>(topic_str.str(), 10, boost::bind(obIcCb, _1, i));
Why do I need to specify the type for the subscribe
call?
If I remove the type specification so that the call is:
ros::Subscriber sub = handle.subscribe(topic_str.str(), 10, boost::bind(obIcCb, _1, i));
Then I get a big error message that says no matching function for call
and many instances of template argument deduction/substitution failed
like this:
error: no matching function for call to ‘ros::NodeHandle::subscribe(std::basic_stringstream<char>::__string_type, int, boost::_bi::bind_t<void, void (*)(std_msgs::Bool_<std::allocator<void>
>, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<unsigned char> > >)’
ros::Subscriber sub = handle.subscribe(topic_str.str(), 10, boost::bind(obIcCb, _1, i));
template argument deduction/substitution failed:
/home/sterlingm/ros_workspace/src/ramp/ramp_planner/src/main_obstacle_twist_all.cpp:357:90: note: mismatched types ‘void (T::*)(M)’ and ‘boost::_bi::bind_t<void, void (*)(std_msgs::Bool_<std::allocator<void> >, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<unsigned char> > >’
ros::Subscriber sub = handle.subscribe(topic_str.str(), 10, boost::bind(obIcCb, _1, i));
When I put the type back in, it compiles. Can someone help explain why I have to specify the type in this call to subscribe
? My callback function is not a class member. It's signature looks like this:
void obIcCb(const std_msgs::Bool data, const int index)
Edit: Very minor edit, just wanted to make it clear that the name in the function signature above matches the name I'm using in my subscribe call.