REAL
Regular Expression Algorithmic Library — constexpr C++20 regex
Loading...
Searching...
No Matches
real::detail::small_vec< T, InlineCapacity >::Storage Union Reference

The either-or storage: the inline buffer, or a pointer to the heap block once the vector has spilled. is_heap_ says which member is active. More...

Collaboration diagram for real::detail::small_vec< T, InlineCapacity >::Storage:
[legend]

Public Member Functions

constexpr Storage () noexcept
 Starts in the inline state.
 
constexpr ~Storage ()
 Destruction handled by cleanup.
 
 Storage (const Storage &)=delete
 
Storageoperator= (const Storage &)=delete
 
 Storage (Storage &&)=delete
 
Storageoperator= (Storage &&)=delete
 

Public Attributes

inline_block inline_buffer
 Inline storage (when not heap).
 
T * heap_ptr
 Heap storage (when is_heap_).
 

Detailed Description

template<typename T, std::size_t InlineCapacity>
union real::detail::small_vec< T, InlineCapacity >::Storage

The either-or storage: the inline buffer, or a pointer to the heap block once the vector has spilled. is_heap_ says which member is active.

Constructor & Destructor Documentation

◆ Storage()

template<typename T , std::size_t InlineCapacity>
constexpr real::detail::small_vec< T, InlineCapacity >::Storage::Storage ( )
inlineconstexprnoexcept

Starts in the inline state.

At run time the inline buffer is left UNINITIALIZED: small_vec writes every element through std::construct_at (placement-new) before any read (push_back and assign), so the value-init is pure overhead — and a tokenizing walk builds a fresh slot buffer per match, of which two slots serve, so it is overhead per match. At compile time the member must be active and initialized for the constexpr matching path (which assigns through inline_data while it is the active member), so it is value-initialized there via construct_at on the whole inline_block — activating a class-type member is what a constexpr union allows (an element-wise or bare C-array activation is not). A constant-evaluated spill switches the active member to Storage::heap_ptr through adopt_heap, and revert_to_inline switches back.


The documentation for this union was generated from the following file: