2#ifndef LIBSBX_CONTAINERS_RING_BUFFER_HPP_
3#define LIBSBX_CONTAINERS_RING_BUFFER_HPP_
8namespace sbx::containers {
10template<
typename Type, std::
size_t Capacity>
15 using value_type = Type;
22 for (
auto i = _head; i != _tail; i = (i + 1) % Capacity) {
23 auto* ptr = _ptr_at(i);
29 auto push(Type&& value)
noexcept ->
void {
30 auto* ptr = _ptr_at(_head);
37 std::construct_at(_ptr_at(_head), std::move(value));
39 _head = (_head + 1) % Capacity;
42 auto capacity()
const noexcept -> std::size_t {
48 auto _ptr_at(std::size_t i) -> Type* {
49 return reinterpret_cast<Type*
>(_buffer + i);
52 alignas(
alignof(Type)) std::byte _buffer[
sizeof(Type) * Capacity];
Definition: ring_buffer.hpp:11