Boost logo

Boost :

Subject: Re: [boost] [STL + allocators] Bug?
From: Phil Endecott (spam_from_boost_dev_at_[hidden])
Date: 2016-02-18 06:30:00

Phil Bouchard wrote:
> I think [std::list etc] should make use of the allocator's specific pointer

In C++03, containers were allowed to assume that allocator::pointer
== value_type*. This is not true since C++11, where it should use
allocator::pointer via allocator_traits.

A subtlety is that in the code you posted you're dealing with node
pointers, not value_type pointers. I'm not sure what's going on there.
My first thought was that you were looking at a pre-11 version of
libstdc++, but I see a #if that suggests otherwise. Maybe others
can comment.

You might like to look at how Boost.Container works. It should use
allocator::pointer even on C++03.

Note that trying to use a smart pointer for allocator::pointer is
unlikely to work in general, e.g. you can't use shared_ptr, because
the semantics are not what the container expects. The most common
use for redefining allocator::pointer that I've seen is to store
offset in memory-mapped files and similar.

Regards, Phil.

Boost list run by bdawes at, gregod at, cpdaniel at, john at