Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how can i mock overloaded template functions #50

Open
duxinyu-uestc opened this issue Jul 14, 2023 · 1 comment
Open

how can i mock overloaded template functions #50

duxinyu-uestc opened this issue Jul 14, 2023 · 1 comment

Comments

@duxinyu-uestc
Copy link

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!

@duxinyu-uestc
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant