Boost logo

Boost :

Subject: Re: [boost] Proposal: Monotonic Containers
From: Christian Schladetsch (christian.schladetsch_at_[hidden])
Date: 2009-06-16 17:14:57


Hi Ross,

//monotonic::inline_storage<1000> store1, store2;
> monotonic::storage<> store1, store2;
> monotonic::allocator<int> alloc1(store1), alloc2(store2);
> std::list<int, monotonic::allocator<int> > list1(alloc1), list2(alloc2);

You can do that, that is fine. Just don't then try to mix the two lists.
Attempts to do so is against the standard. The standard states that an STL
implementation is allowed to treat two allocators of the same type
isomorphically, however monotonic allocators have non-static data.

So if you use two different monotonic storages like that, then splice
between the lists, the behavior is undefined. It may work on some platforms,
like MSVC, but for example it throws an assertion on GCC.

I suggest that if you wish to write safe cross-platform code, that you limit
yourself to using just one monotonic::storage for each collection of
containers. Attempting to mix between them can indeed work, but there are
known problems with this approach on some platforms and this usage is not
supported.

Regards,
Christian.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk