|
Boost : |
Subject: Re: [boost] Proposal: Monotonic Containers
From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2009-06-10 11:00:24
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Wednesday 10 June 2009, Christian Schladetsch wrote:
> However, boost::monotonic provides an allocator that means that *all* STL
> containers - and other ones - can use the stack for storage. Or the heap.
Not the containers specified by c++03. Quoting from the allocator
requirements section 20.1.5:
"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 32.
â All instances of a given allocator type are required to be interchangeable
and always compare equal to each other."
which implies they are only required to support stateless allocators. I do
believe providing an allocator that supports stack allocation with buffer
fallback is the way to go though. It could still be used portably with the
containers Ion mentioned that support stateful allocators.
Or, you might be able to use the old trick of storing state used by the
allocator immediately before the allocated buffer. That is, allocate a
larger block than requested, use the beginning for state, and return a
pointer offset beyond the state information.
Also, is monotonic a good name? std::vector grows its capacity monotonically
too, so it doesn't seem to capture any novel feature of your code over
existing standard features.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAkovyokACgkQ5vihyNWuA4WHTwCfaN3mlYfuaUFmCqAL0vUmc0z5
NIEAoKJ/wwAxwDT1+1U8yAyd23LIewQB
=UXSJ
-----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