REAL
Regular Expression Algorithmic Library — constexpr C++20 regex
Loading...
Searching...
No Matches
real::detail::name_context_box Class Reference

A uniquely-owning, deep-copying box for owned_name_context that survives constant evaluation. More...

#include <storage.hpp>

Collaboration diagram for real::detail::name_context_box:
[legend]

Public Member Functions

constexpr name_context_box () noexcept=default
 Constructs an empty box, owning nothing.
 
constexpr name_context_box (const name_context_box &other)
 Deep-copies the other box's context, if it has one.
 
constexpr name_context_box (name_context_box &&other) noexcept
 Takes over the other box's context, leaving it empty.
 
constexpr name_context_box & operator= (const name_context_box &other)
 Deep-copy assignment.
 
constexpr name_context_box & operator= (name_context_box &&other) noexcept
 Move assignment.
 
constexpr ~name_context_box ()
 Releases the owned context, if any.
 
constexpr void emplace (std::string pattern, std::vector< named_group > names)
 Replaces the owned context with one built from pattern and names.
 
constexpr const owned_name_context * get () const noexcept
 Returns the owned context, or nullptr when the box is empty.
 

Private Member Functions

constexpr void adopt (const owned_name_context &src)
 Allocates and copy-constructs a context from src.
 
constexpr void release () noexcept
 Releases the owned context. Precondition: the box owns one.
 
constexpr void reset () noexcept
 Destroys and deallocates the owned context, if any.
 

Private Attributes

owned_name_context * ptr_ {nullptr}
 The owned context, or nullptr.
 

Detailed Description

A uniquely-owning, deep-copying box for owned_name_context that survives constant evaluation.

No standard smart pointer is literal, and a constant-evaluable real::regex needs a literal result; std::allocator is the only constexpr-usable source, and its blocks are transient. Deep copy, not shared: the box is null on every borrowing result, so that path pays a pointer and a null test.

Constructor & Destructor Documentation

◆ name_context_box() [1/2]

constexpr real::detail::name_context_box::name_context_box ( const name_context_box &  other)
inlineconstexpr

Deep-copies the other box's context, if it has one.

Parameters
[in]otherThe box to copy.

◆ name_context_box() [2/2]

constexpr real::detail::name_context_box::name_context_box ( name_context_box &&  other)
inlineconstexprnoexcept

Takes over the other box's context, leaving it empty.

Parameters
[in,out]otherThe box to move from.

Member Function Documentation

◆ adopt()

constexpr void real::detail::name_context_box::adopt ( const owned_name_context &  src)
inlineconstexprprivate

Allocates and copy-constructs a context from src.

Reached only behind an [[unlikely]] test, by a copy of a result detached from a temporary regex: a warm path here would bid for the unit's inline budget against the scan routes.

Parameters
[in]srcThe context to copy.

◆ emplace()

constexpr void real::detail::name_context_box::emplace ( std::string  pattern,
std::vector< named_group >  names 
)
inlineconstexpr

Replaces the owned context with one built from pattern and names.

Parameters
[in]patternThe pattern text to own.
[in]namesThe named-group table to own.

◆ get()

constexpr const owned_name_context * real::detail::name_context_box::get ( ) const
inlineconstexprnoexcept

Returns the owned context, or nullptr when the box is empty.

Returns
The owned context, or nullptr.

◆ operator=() [1/2]

constexpr name_context_box & real::detail::name_context_box::operator= ( const name_context_box &  other)
inlineconstexpr

Deep-copy assignment.

Parameters
[in]otherThe box to copy.
Returns
*this.

◆ operator=() [2/2]

constexpr name_context_box & real::detail::name_context_box::operator= ( name_context_box &&  other)
inlineconstexprnoexcept

Move assignment.

Parameters
[in,out]otherThe box to move from.
Returns
*this.

◆ release()

constexpr void real::detail::name_context_box::release ( )
inlineconstexprprivatenoexcept

Releases the owned context. Precondition: the box owns one.

Split out of reset, behind its [[unlikely]] test: a borrowing result runs the null test only.


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