22 May
2020
22 May
'20
11:32 a.m.
On Fri, 22 May 2020, 11:24 Andrey Semashev via Boost,
circular_buffer is not a queue. The important difference is that it overwrites older elements as you keep pushing new elements into it.
That's just the behaviour when you run out of capacity. Nothing prevents you from checking you're out of capacity and have different behaviour instead. As I said, the main advantage is avoiding dynamic memory allocations You cannot avoid memory allocations if your queue is unbounded. If pre-allocation of some size is a concern you can just use an adequate allocator. For full memory management flexibility one can also build a circular buffer view on a manually managed contiguous piece of memory.