Boost logo

Boost :

Subject: Re: [boost] Proposal: Monotonic Containers
From: Christian Schladetsch (christian.schladetsch_at_[hidden])
Date: 2009-06-09 21:22:01


Hello,

The initial (and only, AFAIK) problem with the given proposal was that the
following code asserted:

    boost::monotonic::inline_storage<100*sizeof(int)> storage1; // create
local storage on the stack
    boost::monotonic::vector<int> deathrow(storage1); // create a
std::vector that uses this storage

    for(int i = 0; i < 100; ++i)
        deathrow.push_back(i);

I offered to get back to the list when I had looked at it. I am doing so
now. The `problem` is that std::vector allocates more than it needs, as you
add to it. So while it may seem fine to allocate space for 100 ints, then
make a monotonic::vector<int> and add 100 ints to it, it will fail to
allocate the required excessively sized buffer.

The `fix` in this case is to simply give it a larger buffer. This has no
impact on the utility of the proposed librrary.

Regards,
Christian.


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