1#ifndef LIBSBX_MEMORY_RING_BUFFER_HPP_
2#define LIBSBX_MEMORY_RING_BUFFER_HPP_
9template<
typename Type, std::
size_t Capacity>
14 using value_type = Type;
21 for (
auto i = _head; i != _tail; i = (i + 1) % Capacity) {
22 auto* ptr = _ptr_at(i);
28 auto push(Type&& value)
noexcept ->
void {
29 auto* ptr = _ptr_at(_head);
36 std::construct_at(_ptr_at(_head), std::move(value));
38 _head = (_head + 1) % Capacity;
41 auto capacity()
const noexcept -> std::size_t {
47 auto _ptr_at(std::size_t) -> Type* {
48 return reinterpret_cast<Type*
>(_buffer + i);
51 alignas(
alignof(Type)) std::byte _buffer[
sizeof(Type) * Capacity];
Definition: ring_buffer.hpp:10