Boost logo

Boost :

From: Neil Groves (neil_at_[hidden])
Date: 2008-01-21 06:02:35


Hi!

I agree with most of the comments from Thorsten. I do however disagree with
point 1. The allocation in the constructor allows zero allocation in the
subsequent push calls. Often a circular_buffer is used in tight loops of
push operations. I would not want the additional overhead of the allocation
check. With types with no-throw guarantee copy constructors I also would not
want the additional possibility of an exception thrown from the push
operation. I would not use this class if the push operation had this
additional overhead.

Neil Groves

On Jan 21, 2008 10:40 AM, Thorsten Ottosen <thorsten.ottosen_at_[hidden]>
wrote:

> Hi Jan,
>
> #1
> I was browsing through the docs in trunk. First I noticed that the
> default constructor has the follwoing postcondition:
>
> capacity() == max_size() && size() == 0
>
> I find that somewhat unfortunate that it allocates a huge amount of
> memory. It seems to me that it is too easy to do that by coincidence.
> The usual rule for std containers is to never allocate by default and
> anticipate a call to reserve() or the first element. It also seems to me
> that this will create problems when the container is used in containers
> that might use default construction.
>
> #2
> I think it would be useful to add a predicate called is_linearized(), so
> one can check if this property holds. Also, if this do hold, I should be
> able the get fast iterators to this linear segment, perhaps by calling
> .base() on the iterators which then simply return a pointer
> (I know I can get the pointers by array_one(), but I would more often
> need the iterators).
>
> #3
> I think it would be useful to add rotate() as a member function. AFAICT,
> it can in many times (if not all) be much faster than std::rotate()
> because it can simply move a few elements and then simply adjust the
> iterators.
>
> -Thorsten
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>


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