
Neil Groves skrev:
I am happy that you are not suggesting allocation in the push operation.
I think that requiring a call to reserve() is surprising behaviour since one would have to call reserve() for the container to work. This is inconsistent with the standard containers in a different manner. I have always wanted my circular_buffer uses to be allocated at full size.
But isn't that 2^32 objects (i.e. *huge*)? (Or am I misunderstanding something?)
Perhaps the default behaviour could remain the same but an additional constructor could be provided to avoid allocation during construction?
Hm. I don't know. There is a lot of existing code that relies on cheap default construction, e.g.: std::map<int,circular_buffer<T>> map; map[ 1 ] = circular_buffer<T>(...); -Thorsten