|
Boost : |
Subject: Re: [boost] Proposal: Monotonic Containers
From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2009-06-16 17:07:02
Ross Levine skrev:
> Hi Christian,
>
> I'm afraid you are incorrect on both issues.
>
> On the issue of non-static data: Allocators are allowed non-static data, but
> STL implementations are allowed to assume that allocators of the same type
> are equal. The statement of interest is in section 20.1.6 of the C++
> standard: "Implementations of containers described in this International
> Standard are permitted to assume that their Allocator
> template parameter meets the following two additional requirements beyond
> those in Table 34.
> â *All instances of a given allocator type are required to be
> interchangeable and always compare equal to each other.*"
> A copy of the draft is available (free) at
> www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1905.pdf. In particular:
>
> monotonic::inline_storage<1000> store1, store2;
> monotonic::allocator<int> alloc1(store1), alloc2(store2);
> std::list<int, monotonic::allocator<int> > list1(alloc1), list2(alloc2);
>
> STL implementations are allowed to assume alloc1 == alloc2, and list1 is
> allowed to allocate using alloc2, and vice versa.
How can list1 ever use alloc2?
> Moreover, it is allowed to use the list splice member on two lists of
> allocators of the same type.
I'm wondering how this leads to any curruption. I'm assuming
1. that memory is never freed
2. that memory is only use locally (in local containers)
so even though some memory is mixed between the two lists, it shouldn't
matter as allocator::deallocate() is a no-op.
What am I missing?
Thanks
-Thorsten
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk