Subject: Re: [boost] [STL + allocators] Bug?
From: Phil Bouchard (philippeb8_at_[hidden])
Date: 2016-02-18 19:09:02
On 02/18/2016 06:30 AM, Phil Endecott wrote:
> Phil Bouchard wrote:
>> I think [std::list etc] should make use of the allocator's specific
> 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.
Thanks for your input... I am trying out boost::container::... right
now and it is not a trivial task to use a smart pointers inside
containers but I think it is possible.
I saw functions like to_raw_pointer() were user before calling the
allocator's constructors & destructors... I believe this should be
cleaned up sooner or later but for now I think I can survive by
overloading only the allocate & deallocate functions.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk