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

Use const& signature for read-only sub callbacks #337

Merged
merged 1 commit into from
Feb 16, 2022

Conversation

aprotyas
Copy link
Member

@aprotyas aprotyas commented Feb 9, 2022

The constant reference message signatures should be preferred over the
shared pointer to constant message signatures for read-only subscriber
callbacks, as discussed in ros2/rclcpp#1598.

As such, it makes sense to migrate to said signatures in the examples.

Note that this should be backported to Galactic only.

Signed-off-by: Abrar Rahman Protyasha aprotyas@u.rochester.edu

The constant reference message signatures should be preferred over the
shared pointer to constant message signatures for read-only subscriber
callbacks, as discussed in ros2/rclcpp#1598.

As such, it makes sense to migrate to said signatures in the examples.

Signed-off-by: Abrar Rahman Protyasha <aprotyas@u.rochester.edu>
@aprotyas
Copy link
Member Author

aprotyas commented Feb 9, 2022

CI
Repos file: https://gist.github.com/aprotyas/dca8fd39a17abacc898fa569e6b50fc5
Build args: --packages-up-to examples_rclcpp_minimal_subscriber
Test args: --packages-select examples_rclcpp_minimal_subscriber
Job: https://ci.ros2.org/job/ci_launcher/9790/

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

Copy link
Member

@wjwwood wjwwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

This isn't strictly required (there's no problem using ::ConstSharedPtr in this case), but I do agree that const & is easier to read and understand and also has no drawback as a recommendation. So 👍 from me.

@adityapande-1995 adityapande-1995 merged commit 0088f1a into master Feb 16, 2022
@delete-merged-branch delete-merged-branch bot deleted the aprotyas/const_ref_sub_callbacks branch February 16, 2022 18:52
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

Successfully merging this pull request may close these issues.

None yet

3 participants