baudvine::RingBuf
STL-like ring buffer in C++11
ringbuf.h File Reference
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <iterator>
#include <memory>
#include <stdexcept>
#include <tuple>
#include <type_traits>

Go to the source code of this file.

Classes

class  baudvine::detail::ringbuf::Iterator< Ptr, AllocTraits, Capacity >
 An iterator into RingBuf. More...
 
class  baudvine::RingBuf< Elem, Capacity, Allocator >
 An STL-like ring buffer with dynamic allocation and compile-time capacity limits. More...
 

Namespaces

 baudvine
 The baudvine "project".
 

Functions

template<typename Ptr , typename AllocTraits , std::size_t Capacity, typename OutputIt >
OutputIt baudvine::copy (const detail::ringbuf::Iterator< Ptr, AllocTraits, Capacity > &begin, const detail::ringbuf::Iterator< Ptr, AllocTraits, Capacity > &end, OutputIt out)
 Copy the elements in the range [begin, end) to a destination range starting at out. More...
 

Detailed Description

Author
Dominic van Berkel

A ring buffer for C++11, with an STL-like interface.

The comments frequently refer to "physical" and "logical" indices. This is meant to make explicit the distinction between:

  • The backing array of RingBuf, which is always of size Capacity + 1 and is allocated once during RingBuf construction. Physical indices are relative to the start of this array.
  • The conceptual ring buffer, which moves around in the backing array and has a variable length. Logical indices are relative to its start ("ring_offset"), and ring_offset + index may exceed Capacity (before wrapping).

Definition in file ringbuf.h.