Subject: Re: [boost] Proposal: Monotonic Containers
From: Ross Levine (ross.levine_at_[hidden])
Date: 2009-06-16 12:45:28
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.
Moreover, it is allowed to use the list splice member on two lists of
allocators of the same type.
This has been pointed out multiple times, and you have yet to acknowledge
the text that is plainly right there. Until you solve this issue, or create
your own containers which explicitly do not make this assumption, I think
your library should not be used, and quite honestly I am trying to be nice
because I think your containers have merit, your repeated disregard for the
c++ language rules is really annoying me.
On Tue, Jun 16, 2009 at 4:07 AM, Christian Schladetsch <
> Hi Ross,
> Sorry for my staccato replies. You caught me on the way out the door from
> work and I only had time to run some tests and post the results.
> In truth, this is a non-issue. The code you presented broke the standard;
> monotonic allocator didn't. Allocators are indeed allowed to have
> There are various solutions to this 'problem':
> * Only use one monotonic::storage. Multiple allocators that use the one
> storage will correctly compare as equal and can be shared.
> * Don't use std::list::splice with multiple allocators with GCC.
> * Fix the standard so that all STL implementations must respect allocator
> inequality. The fact that they are not required to is an anachronism. It is
> certainly possible.
> * Use a single static 'storage'. I hate this the most.
> None of these invalidate the library as it stands.
> BTW, this has nothing to do with my original code that you quoted where a
> vector migrates from the stack to the heap transparently.
> > I have a few ideas and might play around with them.
> I'm interested in hearing your thoughts on how the larger issue could be
> addressed. But as noted, it is not me that is breaking the standard if you
> splice between two lists that are using different allocators.
> Unsubscribe & other changes:
Boost list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk