Boost logo

Boost :

From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2008-01-21 15:54:46

Jan Gaspar skrev:
> #1
> I don't agree. I tried to design the circular_buffer as close as possible to the other std containers.
> Suppose the cirular_buffer does not allocate anything on construction
- this means when you insert an element to the buffer, it will not be
inserted because the capacity is 0.
> I think this is unnatural for std containers. On the other hand there
is a note in the documentation that you should
>avoid using this constructor: "This constructor has been defined only
due to compatibility with the STL container definition. Avoid using it
because it may allocate very large amount of memory."

My point is that you cannot always control the use of the default
constructor ... libraries call it now and then, and it pretty much
renders circular_buffer unusable with those libraries.

Insertion is already different for circular_buffer, so I don't think it
is that important that push_back() does not insert anything. Instead,
add an assertion check to all insertion function that the capacity is >
0, and specify this as a precondition to all those functions.

> #2
> Agree with is_linearized(), I don't agree with special iterator - I cannot see the point - just use pointers as you mentioned.

Right, but I would prefer an easy, idiomatic way to get those pointers.

> #3
> Yes, maybe in the next version. What would be the method signature?

I guess this would be handy:

void rotate( const_iterator newBegin );
    precondition: newBegin in [begin(),end()).

if we added a new overload taking three iterator arguments like,
std::rotate(), I think it might not yield any performance improvement
over the std::version.


Boost list run by bdawes at, gregod at, cpdaniel at, john at