Bug report
Required Info:
- Operating System:
- Installation type:
- Version or commit hash:
- DDS implementation:
- Client library (if applicable):
Steps to reproduce issue
The LoanedMessage class is defined with an AllocatorT template parameter which is used as the type for the message_allocator_ member variable:
template<typename MessageT, typename AllocatorT = std::allocator<void>>
class LoanedMessage
{
using MessageAllocatorTraits = rclcpp::allocator::AllocRebind<MessageT, AllocatorT>;
using MessageAllocator = typename MessageAllocatorTraits::allocator_type;
MessageAllocator message_allocator_;
};
However, the constructor accepts an allocator parameter which is of type std::allocator<MessageT>:
LoanedMessage(
const rclcpp::PublisherBase & pub,
MessageAllocator allocator)
: pub_(pub),
message_(nullptr),
message_allocator_(std::move(allocator))
{
}
This prevents creating instances of LoanedMessage when using a custom allocator which is not based on std::allocator. Our recommendation to resolve this issue is to modify the constructor to use MessageAllocator as the type for the allocator parameter:
LoanedMessage(
const rclcpp::PublisherBase & pub,
- std::allocator<MessageT> allocator)
+ MessageAllocator allocator)
: pub_(pub),
message_(nullptr),
message_allocator_(std::move(allocator))
{
}
Bug report
Required Info:
Steps to reproduce issue
The
LoanedMessageclass is defined with anAllocatorTtemplate parameter which is used as the type for themessage_allocator_member variable:However, the constructor accepts an
allocatorparameter which is of typestd::allocator<MessageT>:This prevents creating instances of
LoanedMessagewhen using a custom allocator which is not based onstd::allocator. Our recommendation to resolve this issue is to modify the constructor to useMessageAllocatoras the type for theallocatorparameter:LoanedMessage( const rclcpp::PublisherBase & pub, - std::allocator<MessageT> allocator) + MessageAllocator allocator) : pub_(pub), message_(nullptr), message_allocator_(std::move(allocator)) { }