Robotics StackExchange | Archived questions

Cannot seem to use custom container allocators without default constructors

I cannot seem to be able to use an allocator with messages were the allocator does not have a default constructor.

There are many reasons why an allocator wont have a default constructor. The biggest one being the allocator requires some context to perform its allocations.

The reason I found for such an allocator not able to be used is because of the ros::VectorSerializer calling resize with default arguments so there is no way to pass the allocator to subobjects that require it inside a vector. (see https://github.com/ros/roscpp_core/blob/7549340c77a577a3927e825c3ac6a0090c6a75ce/roscpp_serialization/include/ros/serialization.h#L356 )

Does anyone know how I could use a custom container allocator with ros messages when the allocator does not have a default constructor?

An immediate work around that I am using is to make a one off allocator that references the context from a global variable for the situation that I am dealing with.

Asked by Fenderson on 2019-07-22 14:49:23 UTC

Comments

Answers