Boost logo

Boost :

From: Howard Hinnant (hinnant_at_[hidden])
Date: 2003-08-30 09:18:11

On Saturday, August 30, 2003, at 9:31 AM, Peter Dimov wrote:

> The stateful allocator problem is a thorny issue too, since to allow
> stateful allocators, one needs to specify whether the stored allocator
> is
> part of the logical state of the object. IE
> vector<T, A> v1(a1);
> vector<T, A> v2(a2);
> v1 = v2; // which allocator does v1 hold now?

Just to throw in my .02:

v1 holds the same allocator as it was constructed with. Rationale:
Allocator state should stay with the memory it allocates so that it can
deallocate it when the time comes (much like the shared_ptr
philosophy). Since vector assignment does not transfer ownership of
memory, it should not assign allocators.

But consider:

swap(v1, v2);

Here memory ownership is swapped between the vectors. Therefore, imho,
allocator state should also be swapped.

(purposefully not addressing or extending the above argument to


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