|
REAL
Regular Expression Algorithmic Library — constexpr C++20 regex
|
A uniquely-owning, deep-copying box for owned_name_context that survives constant evaluation. More...
#include <storage.hpp>
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. | |
A uniquely-owning, deep-copying box for owned_name_context that survives constant evaluation.
std::shared_ptr is the obvious handle here and cannot be used: a real::regex is constant-evaluable, so the result type it yields must stay literal, and no standard smart pointer is. std::allocator is the only constexpr-usable source in C++20 – the same reason small_vec grows through it – and its blocks are transient, so this releases unconditionally.
Deep copy rather than shared: the box is null on every result that borrows, which is every result a walk or an lvalue regex produces, so nothing on the path that matters ever copies one. What the borrowing path pays is a pointer and a null test.
|
inlineconstexpr |
Deep-copies the other box's context, if it has one.
| [in] | other | The box to copy. |
|
inlineconstexprnoexcept |
Takes over the other box's context, leaving it empty.
| [in,out] | other | The box to move from. |
|
inlineconstexprprivate |
Allocates and copy-constructs a context from src.
Cold: only a result detached from a temporary regex ever owns a context, and only a copy of one ever reaches here. Left warm it bids for the translation unit's inline budget against the scan routes, and takes it from them – the same non-monotonic budget effect build_byte_program is annotated for.
| [in] | src | The context to copy. |
|
inlineconstexpr |
Replaces the owned context with one built from pattern and names.
| [in] | pattern | The pattern text to own. |
| [in] | names | The named-group table to own. |
|
inlineconstexprnoexcept |
Returns the owned context, or nullptr when the box is empty.
nullptr.
|
inlineconstexpr |
Deep-copy assignment.
| [in] | other | The box to copy. |
*this.
|
inlineconstexprnoexcept |
Move assignment.
| [in,out] | other | The box to move from. |
*this.
|
inlineconstexprprivatenoexcept |
Releases the owned context. Precondition: the box owns one.
Split out of reset, and cold for the same reason as the copy path above: every result on the borrowing path runs the null test and nothing else.