ROS 2 rclcpp + rcl - jazzy
jazzy
ROS 2 C++ Client Library with ROS Client Library
|
Template metaprogramming helper used to resolve the callback argument into a std::function. More...
#include <rclcpp/detail/subscription_callback_type_helper.hpp>
Public Types | |
using | callback_type = typename rclcpp::function_traits::as_std_function< CallbackT >::type |
Template metaprogramming helper used to resolve the callback argument into a std::function.
Sometimes the CallbackT is a std::function already, but it could also be a function pointer, lambda, bind, or some variant of those. In some cases, like a lambda where the arguments can be converted between one another, e.g. std::function<void (shared_ptr<...>)> and std::function<void (unique_ptr<...>)>, you need to make that not ambiguous by checking the arguments independently using function traits rather than rely on overloading the two std::function types.
This issue, with the lambda's, can be demonstrated with this minimal program:
If this program ever starts working in a future version of C++, this class may become redundant.
This helper works by using SFINAE with rclcpp::function_traits::same_arguments<> to narrow down the exact std::function<> type for the given CallbackT.
Definition at line 65 of file subscription_callback_type_helper.hpp.