0
$\begingroup$

Rosanswers logo

Is it possible to do that? Like

template <typename T>
class CustomerPublisher : public rclcpp::Node
{
   ...
   typename rclcpp::Publisher<T>::SharedPtr publisher_;
}

I tried it and instantiate a CustomerPublisher<std_msgs::msg::String>. It is able to compile, but got the following error

...undefined reference to `CustomerPublisher<std_msgs::msg::String_<std::allocator<void> > >::publish(std_msgs::msg::String_<std::allocator<void> >)'

Originally posted by ahtsan on ROS Answers with karma: 112 on 2019-07-11

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Answering myself: Do the function definition in .hpp works.


Originally posted by ahtsan with karma: 112 on 2019-07-11

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.