-
Notifications
You must be signed in to change notification settings - Fork 430
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
type trait: rclcpp::is_pointer<T> #817
Conversation
Signed-off-by: Karsten Knese <karsten@openrobotics.org>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation LGTM.
This could live in rcpputils
repo.
If you want to use it here: https://github.com/ros/diagnostics/blob/4edd6dfe6af8950d63d29d9f436bef87a015c316/diagnostic_updater/include/diagnostic_updater/diagnostic_updater.hpp#L373-L380, I don't agree with the usage. The Updater
constructor should take a rclcpp::Node &
.
I am okay with having it on rcpputils, I can reopen the PR over there. The motivation for this is actually exactly to avoid forcing a constructor taking a ‘rclcpp::Node’ because it doesn’t allow for its derivates or similar nodes such as ‘rclcpp::LifecycleNode’. |
That sounds good. But I don't know why accepting all the possible pointers to them. We are already doing something similar of what you want (which it doesn't follow the guidelines I copied either). See:
|
I totally agree, however there is no free functions for |
{}; | ||
|
||
template<class T> | ||
struct is_pointer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding some doc here would be great IMHO
+1 for rcpputils, happy to review the PR there. |
I think we should add I don't like the idea of templated functions accepting any kind of pointer, so I'm not in favor of adding |
{}; | ||
|
||
template<class T> | ||
struct is_smart_pointer_helper<std::shared_ptr<T>>: std::true_type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can't hide these because templates, but I assume that the helper
s aren't part of the public API. might it make sense to nest them in a rcpputils::impl
namespace so at least it's clear they're not part of the public API?
And agreed with thomas on value of adding some doc strings
@Karsten1987 friendly ping, is the plan to move this to |
closing in favor of ros2/rcpputils#19 |
Signed-off-by: ahcorde <ahcorde@gmail.com>
This is a type trait to check whether a parameter is a pointer. This is essentially an extension to
std::is_pointer<T>
which also checks forstd::shared_ptr<T>
as well asstd::unique_ptr<T>
.The use case for this is to pass in a pointer to a node independently whether it's a shared pointer or a raw pointer. Motivation for this see here: https://github.com/ros/diagnostics/pull/112/files#r310801219
Signed-off-by: Karsten Knese karsten@openrobotics.org