C++ Logo


Advanced search

Re: [SG16] [boost] [review] [text] Text formal review

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Sun, 21 Jun 2020 18:54:24 +0300
On Sun, 21 Jun 2020 at 18:32, Vinnie Falco via SG16
<sg16_at_[hidden]> wrote:
> If the author decides to add allocator support, I suggest rather than
> using an Allocator template parameter, to instead use
> `boost::container::memory_resource&` as a constructor parameter (or
> `std::pmr::memory_resource&` if available). This allows the container
> to be implemented as an ordinary class instead of a class template.

The unfortunate bit in doing that is that a memory_resource doesn't
provide hooks
for deciding how it propagates, so you'll be nailing that question
down to one answer.
It sure looks to me that there's more than one answer to that question.

If you're using an allocator, make it a template parameter. Some
proponents of polymorphic
allocators tell their audiences that with the advent of polymorphic
allocators, allocators
as template parameters become unnecessary. Based on my experience in this area,
they are mistaken.

Or perhaps in other words: a memory_resource is not an allocator. It's
a mechanism for acquiring
and releasing memory, but that's not all an allocator is, there's more
to it than that.

Received on 2020-06-21 10:57:46