Skip to content

Subscription callback should support const reference by default #281

Description

@geoffviola

I noticed that the any_subscription_callback supports shared_ptr and unique_ptr, but not const&: https://github.com/ros2/rclcpp/blob/master/rclcpp/include/rclcpp/any_subscription_callback.hpp. It seems simpler to have const& on the subscription callback. The user almost always uses the data in the callback scope. Generally, he will not change the owner of the message data to avoid copying. The rclpcc example should use it: https://github.com/ros2/examples/blob/master/rclcpp_examples/src/topics/listener.cpp.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions