Boost logo

Boost :

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


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

On Wednesday 10 June 2009, Christian Schladetsch wrote:
> monotonic::storage<100*sizeof(int)> storage; //< on the stack! not on the
> heap, as others have suggested
> monotonic::vector<int> v(storage);
> for (int n = 0; n < 100; ++n)
> v.push_back(n); // will fail at n = 34 with an exhausted storage
>
> but this succeeds:
> monotonic::storage<100*sizeof(int)> storage;
> monotonic::vector<int> v(100, storage); // create with an initial size and
> storage
> for (int n = 0; n < 100; ++n)
> v[n] = n;
>
> As the vector in the first case expands, it resizes. But the old memory is
> not freed - that is why it is explicitly called a "monotonic allocator".

Have you considered also supporting a slightly modified allocator that falls
back on the heap once the initial storage is exhausted? I'm more interested
in a small buffer optimization while still supporting larger buffers, rather
than restricting usage to a fixed storage size.

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

iEYEARECAAYFAkoxAMEACgkQ5vihyNWuA4XcjQCgihXSDr6ZpAOqeq9wZVxLGXV3
hpcAniShoS7yU11EtR5pFO8CYv2ZF/nL
=DNgA
-----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