Skip to content

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

Merged
adityapande-1995 merged 1 commit intomasterfrom
aprotyas/const_ref_sub_callbacks
Feb 16, 2022
Merged

Use const& signature for read-only sub callbacks#337
adityapande-1995 merged 1 commit intomasterfrom
aprotyas/const_ref_sub_callbacks

Conversation

@aprotyas
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

3 participants