
-----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-----