REAL
Regular Expression Algorithmic Library — constexpr C++20 regex
Loading...
Searching...
No Matches
real::detail::static_vec< T, Cap > Class Template Reference

Fixed-capacity vector backed by an inline array (no heap). More...

#include <storage.hpp>

Public Member Functions

constexpr void push_back (const T &value)
 Appends value.
 
constexpr void clear ()
 Removes all elements (capacity unchanged).
 
constexpr void assign (std::size_t count, const T &value)
 Resizes to count copies of value.
 
constexpr std::size_t size () const
 Returns the number of elements.
 
constexpr bool empty () const
 Returns true if empty.
 
constexpr T & operator[] (std::size_t i)
 Returns reference to the element at i.
 
constexpr const T & operator[] (std::size_t i) const
 Returns const reference to the element at i.
 
constexpr T & back ()
 Returns reference to the last element. Precondition: the vector is non-empty.
 
constexpr void pop_back ()
 Removes the last element. Precondition: the vector is non-empty.
 

Private Attributes

std::array< T, Cap > data_ {}
 Inline element storage.
 
std::size_t size_ {}
 Number of elements in use.
 

Detailed Description

template<typename T, std::size_t Cap>
class real::detail::static_vec< T, Cap >

Fixed-capacity vector backed by an inline array (no heap).

The subset of std::vector the Pike VM uses, for the static storage mode. Overflow cannot happen for the engine's own containers: static_storage sizes each one exactly via its measure pass, so the length_error guards are an unreachable structural safety net — kept deliberately, and never hit at run time (hence not covered by the runtime coverage report).

Template Parameters
TElement type.
CapInline capacity.

Definition at line 90 of file storage.hpp.

Member Function Documentation

◆ assign()

template<typename T , std::size_t Cap>
constexpr void real::detail::static_vec< T, Cap >::assign ( std::size_t  count,
const T &  value 
)
inlineconstexpr

Resizes to count copies of value.

Parameters
[in]countNumber of elements.
[in]valueThe value to fill with.
Exceptions
std::length_errorif count exceeds the capacity Cap.

Definition at line 122 of file storage.hpp.

◆ back()

template<typename T , std::size_t Cap>
constexpr T & real::detail::static_vec< T, Cap >::back ( )
inlineconstexpr

Returns reference to the last element. Precondition: the vector is non-empty.

Definition at line 173 of file storage.hpp.

◆ clear()

template<typename T , std::size_t Cap>
constexpr void real::detail::static_vec< T, Cap >::clear ( )
inlineconstexpr

Removes all elements (capacity unchanged).

Definition at line 111 of file storage.hpp.

◆ empty()

template<typename T , std::size_t Cap>
constexpr bool real::detail::static_vec< T, Cap >::empty ( ) const
inlineconstexpr

Returns true if empty.

Definition at line 145 of file storage.hpp.

◆ operator[]() [1/2]

template<typename T , std::size_t Cap>
constexpr T & real::detail::static_vec< T, Cap >::operator[] ( std::size_t  i)
inlineconstexpr

Returns reference to the element at i.

Parameters
[in]iIndex.
Returns
Reference to the element at i.

Definition at line 155 of file storage.hpp.

◆ operator[]() [2/2]

template<typename T , std::size_t Cap>
constexpr const T & real::detail::static_vec< T, Cap >::operator[] ( std::size_t  i) const
inlineconstexpr

Returns const reference to the element at i.

Parameters
[in]iIndex.
Returns
Const reference to the element at i.

Definition at line 165 of file storage.hpp.

◆ pop_back()

template<typename T , std::size_t Cap>
constexpr void real::detail::static_vec< T, Cap >::pop_back ( )
inlineconstexpr

Removes the last element. Precondition: the vector is non-empty.

Definition at line 182 of file storage.hpp.

◆ push_back()

template<typename T , std::size_t Cap>
constexpr void real::detail::static_vec< T, Cap >::push_back ( const T &  value)
inlineconstexpr

Appends value.

Parameters
[in]valueThe element to append.
Exceptions
std::length_errorif the capacity Cap is exceeded.

Definition at line 99 of file storage.hpp.

◆ size()

template<typename T , std::size_t Cap>
constexpr std::size_t real::detail::static_vec< T, Cap >::size ( ) const
inlineconstexpr

Returns the number of elements.

Definition at line 137 of file storage.hpp.

Member Data Documentation

◆ data_

template<typename T , std::size_t Cap>
std::array<T, Cap> real::detail::static_vec< T, Cap >::data_ {}
private

Inline element storage.

Definition at line 190 of file storage.hpp.

◆ size_

template<typename T , std::size_t Cap>
std::size_t real::detail::static_vec< T, Cap >::size_ {}
private

Number of elements in use.

Definition at line 191 of file storage.hpp.


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