41 if (
size_ == 0)
throw std::out_of_range(
"CircularBuffer::latest - buffer empty");
49 if (i >=
size_)
throw std::out_of_range(
"CircularBuffer::from_end - index too large");
57 if (index >=
size_)
throw std::out_of_range(
"CircularBuffer::operator[] - index too large");
void set_capacity(size_t capacity)
const T & from_end(size_t i) const
Access i-th element from the end (0 = latest, 1 = previous, ...)
CircularBuffer(size_t capacity=0)
void push(const T &item)
Add item into circular buffer.
const T & operator[](size_t index) const
Iterate raw access.
const T & latest() const
Access the most recent item.