Boost logo

Boost :

Subject: Re: [boost] Proposal: Monotonic Containers
From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2009-06-09 14:40:49


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tuesday 09 June 2009, Ross Levine wrote:
> To summarize, std::vector<T, monotonic_allocator<T> > won't work if each
> vector gets a specific buffer, because another vector could possibly use
> that buffer instead! Thus a custom version of each container is REQUIRED
> unless there's a boost.test macro BOOST_STL_ALLOCATOR_EQUIVALENCE or
> something like that.

It seems like you could make a stack-backed vector work in c++03 by building
it on top of something like

std::vector<object_wrapper<T>, monotonic_allocator<T> >

where object_wrapper<T> contains the T value plus a pointer to an object that
holds the needed per-container allocator state. That gets you around the
stateless allocator problem at the expense of having to store an extra
pointer for each object in your container.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkourLEACgkQ5vihyNWuA4UCCQCgtSRCUzbA3ufAJKEBdyHSRYN2
t6wAoNvX1FgdVCA5Myk03m0HTX9LbIMl
=gk43
-----END PGP SIGNATURE-----


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