mockcpp
mockcpp copied to clipboard
how can i mock overloaded template functions
i try to mock overloaded template functions:
template <typename M>
void publish(const boost::shared_ptr<M>& message) const
{
//do
}
template <typename M>
void publish(const M& message) const
{
//do
}
my code is :
MOCKER((void(ros::Publisher::*)(const map_service::MapChanged &))&ros::Publisher::publish<const map_service::MapChanged &>)
.stubs();
i want to mock the second template function, but it doesn't work. Thanks for your help!
error is:
error: no matches converting function 'publish' to type 'void (class ros::Publisher::*)(const MapChanged&) {aka void (class ros::Publisher::*)(const struct map_service::MapChanged_<std::allocator<void> >&)}'
and list several forms of overloaded template functions , Its meaning may be that it cannot match which specific function is required