Overview / Foundation

containers

Fixed-capacity structures that never touch the allocator after construction. Templates only.

Always compiled: part of the core build.Include #include <ethereal/cpp/containers/containers_inc.hpp>C layer

containers_inc.hpp

#include <ethereal/cpp/containers/containers_inc.hpp>

fixed_vector.hpp

#include <ethereal/cpp/containers/fixed_vector.hpp>

Contiguous sequence with fixed capacity, without heap.

class

CFixedVector

Ethereal::Containers#

Contiguous sequence with fixed capacity, without dynamic allocation.

template< typename T, std::size_t Capacity > class CFixedVector final

All the storage lives inside the object. No operation touches the allocator, not at construction, not when growing, because it does not grow.

It exists for the reason the Assert module writes at the top of its .cpp: the failure path cannot allocate, because an assertion often fires exactly when the allocator is corrupt, and a report that allocates turns a diagnosable defect into a hang. The same rule applies to signal handlers and to code inside destructors.

The contract differs from std::vector on purpose: going over the capacity neither grows nor throws, it returns false. The caller decides what to do with the excess.

T
Element type. Must be default constructible and assignable.
Capacity
Maximum number of elements. Must be greater than zero.
Not guaranteed to be thread safe.
alias

value_type

#
using value_type = T;

Element type.

alias

size_type

#
using size_type = std::size_t;

Size type.

const

MaxSize

#
static constexpr size_type MaxSize = Capacity;

Maximum capacity, known at compile time.

constructor

CFixedVector

#
CFixedVector() noexcept : m_uSize( 0 )

Creates an empty vector.

function

PushBack

#
bool PushBack( const T & Value )

Appends an element at the end.

Value
The element.
false when already full. The container is left unchanged.
function

PushBack

#
bool PushBack( T && Value )

Appends an element at the end, moving it.

function

PopBack

#
bool PopBack()

Removes the last element.

The removed element is assigned a T() so the container does not hold resources of something that already left. It matters when T holds a pointer, a descriptor or a std::function.

false when empty.
function

Clear

#
void Clear()

Empties the container, releasing the elements.

operator

operator[]

#
T & operator[]( const size_type uIndex ) noexcept

Access by index, without bounds checking.

The index must be smaller than Size.
operator

operator[]

#
const T & operator[]( const size_type uIndex ) const noexcept
function

Data

#
T * Data() noexcept

Pointer to the contiguous storage.

function

Data

#
const T * Data() const noexcept
function

begin

#
T * begin() noexcept

Iterators, so the container works in a range for loop.

function

end

#
T * end() noexcept
function

begin

#
const T * begin() const noexcept
function

end

#
const T * end() const noexcept
function

Size

#
size_type Size() const noexcept

Number of elements.

function

IsEmpty

#
bool IsEmpty() const noexcept

true when empty.

function

IsFull

#
bool IsFull() const noexcept

true when full.

ring_buffer.hpp

#include <ethereal/cpp/containers/ring_buffer.hpp>

Circular buffer with fixed capacity that keeps the last N elements.

class

CRingBuffer

Ethereal::Containers#

Circular queue with fixed capacity, without dynamic allocation.

template< typename T, std::size_t Capacity > class CRingBuffer final

Keeps the last Capacity elements. When full, Push drops the oldest one to make room. Whoever must refuse instead of dropping uses TryPush.

It is the structure for records that cannot grow without bound: the last N log lines, the last N telemetry samples, the last N events before a failure. The Log module already has fixed buffer sizes in the ELoggingBufferSizes enumeration and does this same work by hand.

Indexing is logical, not physical: operator[](0) is always the oldest element still present, wherever it is in the internal array.

T
Element type. Must be default constructible and assignable.
Capacity
Number of elements kept. Must be greater than zero.
Not guaranteed to be thread safe. For exchange between two threads, see CSpscQueue.
alias

value_type

#
using value_type = T;

Element type.

alias

size_type

#
using size_type = std::size_t;

Size type.

const

MaxSize

#
static constexpr size_type MaxSize = Capacity;

Number of elements kept, known at compile time.

constructor

CRingBuffer

#
CRingBuffer() noexcept : m_uFirst( 0 ), m_uSize( 0 )

Creates an empty buffer.

function

Push

#
bool Push( const T & Value )

Appends an element, dropping the oldest one when needed.

Value
The element.
true when something was dropped to make room.
function

TryPush

#
bool TryPush( const T & Value )

Appends an element only when there is room.

Value
The element.
false when full. Nothing is dropped.
function

Pop

#
bool Pop( T & OutValue )

Takes out the oldest element.

OutValue
Receives the element.
false when empty.
function

Clear

#
void Clear()

Empties the buffer, releasing the elements.

operator

operator[]

#
T & operator[]( const size_type uIndex ) noexcept

Logical access: index 0 is the oldest element still present.

The index must be smaller than Size.
operator

operator[]

#
const T & operator[]( const size_type uIndex ) const noexcept
function

Front

#
T & Front() noexcept

The oldest element. Only valid when not empty.

function

Front

#
const T & Front() const noexcept
function

Back

#
T & Back() noexcept

The newest element. Only valid when not empty.

function

Back

#
const T & Back() const noexcept
function

Size

#
size_type Size() const noexcept

Number of elements.

function

IsEmpty

#
bool IsEmpty() const noexcept

true when empty.

function

IsFull

#
bool IsFull() const noexcept

true when full.

spsc_queue.hpp

#include <ethereal/cpp/containers/spsc_queue.hpp>

Lock free queue for one producer and one consumer.

class

CSpscQueue

Ethereal::Containers#
template< typename T, std::size_t Capacity > class CSpscQueue final
alias

value_type

#
using value_type = T;

Element type.

alias

size_type

#
using size_type = std::size_t;

Size type.

const

MaxSize

#
static constexpr size_type MaxSize = Capacity;

Maximum number of pending elements.

constructor

CSpscQueue

#
CSpscQueue() noexcept : m_uHead( 0 ), m_uTail( 0 )

Creates an empty queue.

function

TryPush

#
bool TryPush( const T & Value )

Enqueues an element. Only the producer thread may call it.

Value
The element.
false when the queue is full. Nothing is enqueued.
function

TryPush

#
bool TryPush( T && Value )

Enqueues an element, moving it. Only from the producer thread.

function

TryPop

#
bool TryPop( T & OutValue )

Dequeues an element. Only the consumer thread may call it.

OutValue
Receives the element.
false when the queue is empty.
function

Size

#
size_type Size() const noexcept

Number of pending elements.

Under concurrency the value is a snapshot, and may already be stale when the call returns. It is fine for metrics and debugging. Deciding control flow with it is a race.

Any thread may call it, including a third one that is neither the producer nor the consumer. The value is always between 0 and Capacity, and normally a count the queue really had at some instant during the call. Until 2026-10-16 it read the tail before the head, and from a third thread the head could pass the tail it had read: the difference wrapped to a huge number.

function

IsEmpty

#
bool IsEmpty() const noexcept

Tells whether the queue is empty. Same caveat as Size.