rclcpp icon indicating copy to clipboard operation
rclcpp copied to clipboard

Make get_rcl_allocator a function family (not a template)

Open stevewolter opened this issue 3 years ago • 10 comments

As explained in #1254, there's conceptually no way to implement RCL allocators in terms of C++ allocators. In order to fix this behavior, we have to delete the generic version of get_rcl_allocator. Since some ROS code depends on this, we need to allow users to write their own version of get_rcl_allocator for allocators that support the C-style interface (most do).

So this CL changes get_rcl_allocator from a template function into a family of (potentially templated) functions, which allows users to add their own overloads and rely on the "most specialized" mechanism for function specialization to select the right one. See http://www.gotw.ca/publications/mill17.htm for details. This also allows us to return get_rcl_default_allocator for all specializations of std::allocator (previously, only for std::allocator), which will already fix #1254 for pretty much all clients. I'll continue to work on deleting the generic version, though, to make sure that nobody is accidentally bitten by it.

I've tried to test this by doing a full ROS compilation following the Dockerfile of the source Docker image, and all packages compile.

stevewolter avatar Sep 22 '20 11:09 stevewolter