|
REAL
Regular Expression Algorithmic Library — constexpr C++20 regex
|
Storage policy backing real::static_regex: compile-time, stateless.
More...
#include <storage.hpp>
Classes | |
| struct | measured |
Everything build yields that is not a range, measured in one evaluation: each build() re-runs the compiler front end, against the constexpr step budget and compile time. More... | |
Public Types | |
| using | name_owner = borrowed_names |
| Name-resolution owner: empty, the tables having static storage duration. | |
| using | slot_storage = static_vec< std::size_t, slot_count > |
| Capture-slot storage, sized exactly to the program's slot count (no heap). | |
| using | state_type = static_pike_scratch< scratch_code_tier(code_size), slot_count, wants_inner_literal > |
| This pattern's VM scratch — nothing but static_pike_scratch at this pattern's dimensions, so two patterns of the same shape name the same type. | |
Public Member Functions | |
| constexpr const program_view & | view () const |
| Returns a non-owning view of the compile-time program, by reference. | |
| constexpr std::string_view | pattern () const |
| Returns the pattern text. | |
| constexpr flags | compiled_flags () const |
Returns the flag set in force: constructor flags, plus a leading global-flags group's additions, minus its -removal – see real::basic_regex::compile_flags. | |
Static Public Attributes | |
| static constexpr bool | is_compile_time {true} |
| Selects the default constructor. | |
| static constexpr bool | viable {requires { typename std::bool_constant<(build(), true)>; }} |
| Whether build is a constant expression for this pattern. | |
| static constexpr measured | survey |
| The one measuring evaluation. Never emitted: nothing takes its address, and every member below reads it at compile time only. | |
| static constexpr flags | effective_flags |
The flag set in force: F plus a leading group's additions, minus its removals, as dynamic_storage::compile reports it. Parsed once. | |
| static constexpr pattern_hints | hints {survey.hints} |
| Search hints. | |
| static constexpr std::size_t | code_size {survey.code_size} |
| Instruction count. | |
| static constexpr std::size_t | class_count {survey.class_count} |
| Distinct class count. | |
| static constexpr std::size_t | name_count {survey.name_count} |
| Named-group count. | |
| static constexpr std::size_t | cp_class_count {survey.cp_class_count} |
| Code-point class count (klass_cp). | |
| static constexpr std::size_t | cp_range_count {survey.cp_range_count} |
| Total code-point ranges. | |
| static constexpr std::uint16_t | slot_count {survey.slot_count} |
2*(groups+1). | |
| static constexpr std::array< instr, code_size > | code {take<instr, code_size>(build().code)} |
| The program. | |
| static constexpr std::array< char_class, class_count > | classes |
| Interned classes. | |
| static constexpr std::array< named_group, name_count > | names |
| Named groups. | |
| static constexpr std::array< cp_class, cp_class_count > | cp_classes |
| Code-point classes. | |
| static constexpr std::array< code_range, cp_range_count > | cp_ranges |
| Flat range buffer. | |
| static constexpr std::array< std::uint8_t,(class_count==0 ? 1 :class_count) *256 > | class_tables |
Flat byte-class membership tables, built at compile time: class_tables[i*256 + b]. Reads classes rather than calling build again, which would pass clang's constexpr step budget. | |
| static constexpr std::array< std::uint8_t,(cp_class_count==0 ? 1 :cp_class_count) *256 > | cp_ascii_tables |
Flat ASCII tables for the code-point classes: cp_ascii_tables[i*256 + b]. | |
| static constexpr std::array< std::uint64_t,(cp_class_count==0 ? 1 :cp_class_count) *30 > | cp_page_tables |
| Two-byte-range membership bitmaps (U+0080..U+07FF) for the code-point classes, 30 words each. | |
| static constexpr bool | wants_inner_literal |
Whether the inner-literal route is worth compiling into this pattern's run(). | |
Static Private Member Functions | |
| static constexpr dynamic_program | build () |
| Returns the freshly built program (used for both measuring and filling). | |
| template<typename T , std::size_t N, typename Vec > | |
| static constexpr std::array< T, N > | take (const Vec &source) |
Copies the first N elements of v into a fixed array. | |
Static Private Attributes | |
| static constexpr program_view | view_ |
| The view itself, materialised once at compile time. See view. | |
Storage policy backing real::static_regex: compile-time, stateless.
Every array is a static constexpr member sized exactly by a measuring pass over the same compilation, so a static_regex object is stateless (sizeof 1) and matching allocates nothing.
| Pat | The pattern, as a real::fixed_string non-type parameter. |
| F | Compilation flags. |
| using real::detail::static_storage< Pat, F >::state_type = static_pike_scratch<scratch_code_tier (code_size), slot_count, wants_inner_literal> |
This pattern's VM scratch — nothing but static_pike_scratch at this pattern's dimensions, so two patterns of the same shape name the same type.
Nothing here may depend on the pattern's value: the table addresses travel in real::detail::program_view (see 10.1 The inlining budget).
|
inlinestaticconstexprprivate |
Returns the freshly built program (used for both measuring and filling).
Runs only at compile time (a static_regex instantiation), so it is invisible to the runtime coverage report; it is exercised by the constexpr static_asserts in tests/test_static.cpp and tests/test_constexpr.cpp.
|
inlineconstexpr |
Returns the flag set in force: constructor flags, plus a leading global-flags group's additions, minus its -removal – see real::basic_regex::compile_flags.
|
inlineconstexpr |
Returns the pattern text.
|
inlinestaticconstexprprivate |
Copies the first N elements of v into a fixed array.
| T | Element type. |
| N | Exact size (measured from build). |
| Vec | Source container type. |
| [in] | source | The source vector. |
|
inlineconstexpr |
Returns a non-owning view of the compile-time program, by reference.
Every field is a compile-time constant, so a reference costs nothing where a by-value return would copy the view per search(), a large share of a short search.
|
staticconstexpr |
Flat byte-class membership tables, built at compile time: class_tables[i*256 + b]. Reads classes rather than calling build again, which would pass clang's constexpr step budget.
|
staticconstexpr |
Interned classes.
|
staticconstexpr |
Flat ASCII tables for the code-point classes: cp_ascii_tables[i*256 + b].
|
staticconstexpr |
Code-point classes.
|
staticconstexpr |
Two-byte-range membership bitmaps (U+0080..U+07FF) for the code-point classes, 30 words each.
|
staticconstexpr |
Flat range buffer.
|
staticconstexpr |
The flag set in force: F plus a leading group's additions, minus its removals, as dynamic_storage::compile reports it. Parsed once.
|
staticconstexpr |
Named groups.
|
staticconstexpr |
The one measuring evaluation. Never emitted: nothing takes its address, and every member below reads it at compile time only.
|
staticconstexpr |
Whether build is a constant expression for this pattern.
A requires expression is a SFINAE context: forming the bool_constant template argument needs a constant expression, and build throwing makes it one substitution failure rather than a hard error. That is what lets viable be asked instead of crashed into.
|
staticconstexprprivate |
The view itself, materialised once at compile time. See view.
|
staticconstexpr |
Whether the inner-literal route is worth compiling into this pattern's run().
A required literal at offset >= 1 is necessary, not sufficient: a fixed_shape pattern already has an arithmetic-width scan and gains nothing, while others gain orders of magnitude on a subject with no match. Decided here, not at run time: compiling the block into run() costs patterns that never enter it.