5

I want to know the history of the standardization of the circular buffer(circular queue or deque).

AFAIK, the current C++ standard(C++ 2023) doesn't provide a circular buffer in the STL. I googled and found only one proposal, ring_span around 2015. Boost has the circular_buffer. Some provide in-house implementations, such as cqueue.

If you repeat push and pop operations with a std::deque, you repeat allocating and freeing heap blocks. In Qt(one of largest C++ projects), the situation is worse, where QQueue keeps allocating heap blocks(and never freeing).

I'm not asking for opinions. I want to know the history. I expect good reasons why it was so hard to standardize the circular buffer.

8
  • 1
    What exactly are you asking for? Boost.CircularBuffer has a fixed capacity. You can change the capacity, but insertions by themselves don't do that. Aug 8 at 2:44
  • 5
    In my experience, every time I want a ring buffer for something, I need to implement it a little differently from the last time. I'm not convinced that standardizing it would change this, and if it did something like throw an exception when pushing onto a full queue, there's a good chance I'd never use it.
    – paddy
    Aug 8 at 2:51
  • 1
    The proposal paper has an email address, you could ask the P0059R4' author directly. He might be the only knowing the true answer.
    – 273K
    Aug 8 at 3:18
  • 3
    This is my impression: Because circular buffer is an underrated data structure. And yes, as @paddy said there are too many details and variants to agree on one, flexible vs fixed, allocating vs. not. Also, it doesn't fit with the framework of 1D containers, as push means also pop, so the discussions about the interface would be endless. Just some theories.
    – alfC
    Aug 8 at 3:47
  • 2
    For something to enter the standard a large number of people on the committee need to agree on it's specification. For something like a circular buffer which is likely to mostly be used in performance critical applications that specification is likely to be highly application specific and finding one specification that fits most use cases and everyone can agree on is very difficult Aug 8 at 6:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.