|
Boost : |
Subject: Re: [boost] [utility] new auto_buffer class --- RFC
From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2009-03-02 11:56:22
John Maddock skrev:
>>> to avoid heap-allocations in 95% of the cases. This can be a major
>>> speed-improvement. For the remaining 5% of the cases, the buffer will be
>>> placed on the heap, but the code from the user's persective remains the
>>> same.
>>
>> - From glancing at the implementation posted to the list, it does not
>> appear to
>> fall back to heap allocation once the maximum stack capacity is reached.
>> push_back() simply asserts that the stack capacity hasn't been used up
>> yet.
Yes, that is necessary to make push_back() inlinable. I also think this
fits most usage scenarios.
> In which case how does this differ from boost::array?
The capacity is fixed (at run-time), but the size is not. The size is
initially 0, but can be expanded (mainly for PODs) with
uninitialized_grow().
I don't use T[N] internally to allow this.
-Thorsten
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk