REAL
Regular Expression Algorithmic Library — constexpr C++20 regex
Loading...
Searching...
No Matches
real::compat::match_results< BidirIt, Alloc > Class Template Reference

The result of a match: group sub-matches plus the prefix and suffix. More...

#include <regex_match.hpp>

Public Types

using value_type = sub_match< BidirIt >
 Element type.
 
using const_reference = const value_type &
 Reference type.
 
using reference = value_type &
 Reference type.
 
using const_iterator = typename std::vector< value_type, Alloc >::const_iterator
 Iterator.
 
using iterator = const_iterator
 Iterators are const (std parity).
 
using difference_type = typename std::iterator_traits< BidirIt >::difference_type
 Distance type.
 
using size_type = std::size_t
 Size type.
 
using char_type = typename std::iterator_traits< BidirIt >::value_type
 Character type.
 
using string_type = std::basic_string< char_type >
 Owning string type.
 

Public Member Functions

bool ready () const noexcept
 Whether a successful match has been stored.
 
size_type size () const noexcept
 Number of marks (groups), including group 0; 0 when there was no match.
 
bool empty () const noexcept
 
const_reference operator[] (size_type n) const
 The sub-match for group n (group 0 is the whole match). Out-of-range n returns a reference to an unmatched sub_match anchored at the sequence end {last_, last_, false}, exactly like std::match_results::operator[] (verified on libc++ and libstdc++) — never out-of-bounds. A token selector {2}/{5} or a negative field relies on this.
 
difference_type position (size_type n=0) const
 Start offset of group n from the sequence start. For an out-of-range group std anchors the sub_match at the end, so the offset is the full sequence length.
 
difference_type length (size_type n=0) const
 Length of group n (0 if out of range or unmatched).
 
string_type str (size_type n=0) const
 Matched text of group n (empty if out of range or unmatched).
 
const value_typeprefix () const
 The unmatched prefix (sequence start up to the whole match).
 
const value_typesuffix () const
 The unmatched suffix (whole match end to sequence end).
 
const_iterator begin () const
 
const_iterator end () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
void reset (BidirIt first, BidirIt last)
 Resets to the not-ready (no-match) state over the sequence [first, last).
 
void set_ready_no_match ()
 Marks a ready but unmatched result — after a failed search/match std leaves ready() == true with size() == 0 (a not-ready result would be a divergence).
 
void rebase_prefix (BidirIt first)
 Re-bases the unmatched prefix to start at first — for iteration, where a match's prefix runs from the previous match's end (not the sequence start). The std path already gets this from the wrapped std::regex_iterator; the real path needs it.
 
template<typename RealMatch >
void fill_from_real (const RealMatch &match)
 Fills from real's byte offsets over the sequence [first_, last_). Templated on the match type — real::regex::search returns an SBO-backed result, not the std::vector-backed real::match_result alias.
 
template<typename StdMatch >
void fill_from_std (const StdMatch &match)
 Copies from a std::match_results (the fallback path) over the same sequence.
 

Private Attributes

BidirIt first_ {}
 Start of the searched sequence.
 
BidirIt last_ {}
 End of the searched sequence.
 
std::vector< value_type, Alloc > groups_
 Group sub-matches (0 = whole match).
 
value_type prefix_ {}
 Unmatched prefix.
 
value_type suffix_ {}
 Unmatched suffix.
 
value_type unmatched_ {}
 Sentinel for out-of-range operator[] (anchored at last_).
 
bool ready_ {false}
 Whether a match is stored.
 

Detailed Description

template<typename BidirIt, typename Alloc = std::allocator<sub_match<BidirIt>>>
class real::compat::match_results< BidirIt, Alloc >

The result of a match: group sub-matches plus the prefix and suffix.

Stores both ends of the searched sequence (first_, last_) so suffix() and lengths are exact (the end is not derivable from a base pointer alone). Filled either from real's byte offsets or copied from a std::match_results on the fallback path.

Template Parameters
BidirItA contiguous iterator into the searched sequence.
AllocAllocator for the sub-match vector (std parity; default suffices).

Definition at line 116 of file regex_match.hpp.

Member Typedef Documentation

◆ char_type

template<typename BidirIt , typename Alloc = std::allocator<sub_match<BidirIt>>>
using real::compat::match_results< BidirIt, Alloc >::char_type = typename std::iterator_traits<BidirIt>::value_type

Character type.

Definition at line 127 of file regex_match.hpp.

◆ const_iterator

template<typename BidirIt , typename Alloc = std::allocator<sub_match<BidirIt>>>
using real::compat::match_results< BidirIt, Alloc >::const_iterator = typename std::vector<value_type, Alloc>::const_iterator

Iterator.

Definition at line 123 of file regex_match.hpp.

◆ const_reference

template<typename BidirIt , typename Alloc = std::allocator<sub_match<BidirIt>>>
using real::compat::match_results< BidirIt, Alloc >::const_reference = const value_type&

Reference type.

Definition at line 121 of file regex_match.hpp.

◆ difference_type

template<typename BidirIt , typename Alloc = std::allocator<sub_match<BidirIt>>>
using real::compat::match_results< BidirIt, Alloc >::difference_type = typename std::iterator_traits<BidirIt>::difference_type

Distance type.

Definition at line 125 of file regex_match.hpp.

◆ iterator

template<typename BidirIt , typename Alloc = std::allocator<sub_match<BidirIt>>>
using real::compat::match_results< BidirIt, Alloc >::iterator = const_iterator

Iterators are const (std parity).

Definition at line 124 of file regex_match.hpp.

◆ reference

template<typename BidirIt , typename Alloc = std::allocator<sub_match<BidirIt>>>
using real::compat::match_results< BidirIt, Alloc >::reference = value_type&

Reference type.

Definition at line 122 of file regex_match.hpp.

◆ size_type

template<typename BidirIt , typename Alloc = std::allocator<sub_match<BidirIt>>>
using real::compat::match_results< BidirIt, Alloc >::size_type = std::size_t

Size type.

Definition at line 126 of file regex_match.hpp.

◆ string_type

template<typename BidirIt , typename Alloc = std::allocator<sub_match<BidirIt>>>
using real::compat::match_results< BidirIt, Alloc >::string_type = std::basic_string<char_type>

Owning string type.

Definition at line 128 of file regex_match.hpp.

◆ value_type

template<typename BidirIt , typename Alloc = std::allocator<sub_match<BidirIt>>>
using real::compat::match_results< BidirIt, Alloc >::value_type = sub_match<BidirIt>

Element type.

Definition at line 120 of file regex_match.hpp.

Member Function Documentation

◆ begin()

template<typename BidirIt , typename Alloc = std::allocator<sub_match<BidirIt>>>
const_iterator real::compat::match_results< BidirIt, Alloc >::begin ( ) const
inline

Definition at line 188 of file regex_match.hpp.

◆ cbegin()

template<typename BidirIt , typename Alloc = std::allocator<sub_match<BidirIt>>>
const_iterator real::compat::match_results< BidirIt, Alloc >::cbegin ( ) const
inline

Definition at line 198 of file regex_match.hpp.

◆ cend()

template<typename BidirIt , typename Alloc = std::allocator<sub_match<BidirIt>>>
const_iterator real::compat::match_results< BidirIt, Alloc >::cend ( ) const
inline

Definition at line 203 of file regex_match.hpp.

◆ empty()

template<typename BidirIt , typename Alloc = std::allocator<sub_match<BidirIt>>>
bool real::compat::match_results< BidirIt, Alloc >::empty ( ) const
inlinenoexcept

Definition at line 142 of file regex_match.hpp.

◆ end()

template<typename BidirIt , typename Alloc = std::allocator<sub_match<BidirIt>>>
const_iterator real::compat::match_results< BidirIt, Alloc >::end ( ) const
inline

Definition at line 193 of file regex_match.hpp.

◆ fill_from_real()

template<typename BidirIt , typename Alloc = std::allocator<sub_match<BidirIt>>>
template<typename RealMatch >
void real::compat::match_results< BidirIt, Alloc >::fill_from_real ( const RealMatch &  match)
inline

Fills from real's byte offsets over the sequence [first_, last_). Templated on the match type — real::regex::search returns an SBO-backed result, not the std::vector-backed real::match_result alias.

Definition at line 243 of file regex_match.hpp.

◆ fill_from_std()

template<typename BidirIt , typename Alloc = std::allocator<sub_match<BidirIt>>>
template<typename StdMatch >
void real::compat::match_results< BidirIt, Alloc >::fill_from_std ( const StdMatch &  match)
inline

Copies from a std::match_results (the fallback path) over the same sequence.

Definition at line 273 of file regex_match.hpp.

◆ length()

template<typename BidirIt , typename Alloc = std::allocator<sub_match<BidirIt>>>
difference_type real::compat::match_results< BidirIt, Alloc >::length ( size_type  n = 0) const
inline

Length of group n (0 if out of range or unmatched).

Definition at line 165 of file regex_match.hpp.

◆ operator[]()

template<typename BidirIt , typename Alloc = std::allocator<sub_match<BidirIt>>>
const_reference real::compat::match_results< BidirIt, Alloc >::operator[] ( size_type  n) const
inline

The sub-match for group n (group 0 is the whole match). Out-of-range n returns a reference to an unmatched sub_match anchored at the sequence end {last_, last_, false}, exactly like std::match_results::operator[] (verified on libc++ and libstdc++) — never out-of-bounds. A token selector {2}/{5} or a negative field relies on this.

Definition at line 151 of file regex_match.hpp.

◆ position()

template<typename BidirIt , typename Alloc = std::allocator<sub_match<BidirIt>>>
difference_type real::compat::match_results< BidirIt, Alloc >::position ( size_type  n = 0) const
inline

Start offset of group n from the sequence start. For an out-of-range group std anchors the sub_match at the end, so the offset is the full sequence length.

Definition at line 158 of file regex_match.hpp.

◆ prefix()

template<typename BidirIt , typename Alloc = std::allocator<sub_match<BidirIt>>>
const value_type & real::compat::match_results< BidirIt, Alloc >::prefix ( ) const
inline

The unmatched prefix (sequence start up to the whole match).

Definition at line 177 of file regex_match.hpp.

◆ ready()

template<typename BidirIt , typename Alloc = std::allocator<sub_match<BidirIt>>>
bool real::compat::match_results< BidirIt, Alloc >::ready ( ) const
inlinenoexcept

Whether a successful match has been stored.

Definition at line 131 of file regex_match.hpp.

◆ rebase_prefix()

template<typename BidirIt , typename Alloc = std::allocator<sub_match<BidirIt>>>
void real::compat::match_results< BidirIt, Alloc >::rebase_prefix ( BidirIt  first)
inline

Re-bases the unmatched prefix to start at first — for iteration, where a match's prefix runs from the previous match's end (not the sequence start). The std path already gets this from the wrapped std::regex_iterator; the real path needs it.

Definition at line 233 of file regex_match.hpp.

◆ reset()

template<typename BidirIt , typename Alloc = std::allocator<sub_match<BidirIt>>>
void real::compat::match_results< BidirIt, Alloc >::reset ( BidirIt  first,
BidirIt  last 
)
inline

Resets to the not-ready (no-match) state over the sequence [first, last).

Definition at line 211 of file regex_match.hpp.

◆ set_ready_no_match()

template<typename BidirIt , typename Alloc = std::allocator<sub_match<BidirIt>>>
void real::compat::match_results< BidirIt, Alloc >::set_ready_no_match ( )
inline

Marks a ready but unmatched result — after a failed search/match std leaves ready() == true with size() == 0 (a not-ready result would be a divergence).

Definition at line 224 of file regex_match.hpp.

◆ size()

template<typename BidirIt , typename Alloc = std::allocator<sub_match<BidirIt>>>
size_type real::compat::match_results< BidirIt, Alloc >::size ( ) const
inlinenoexcept

Number of marks (groups), including group 0; 0 when there was no match.

Definition at line 137 of file regex_match.hpp.

◆ str()

template<typename BidirIt , typename Alloc = std::allocator<sub_match<BidirIt>>>
string_type real::compat::match_results< BidirIt, Alloc >::str ( size_type  n = 0) const
inline

Matched text of group n (empty if out of range or unmatched).

Definition at line 171 of file regex_match.hpp.

◆ suffix()

template<typename BidirIt , typename Alloc = std::allocator<sub_match<BidirIt>>>
const value_type & real::compat::match_results< BidirIt, Alloc >::suffix ( ) const
inline

The unmatched suffix (whole match end to sequence end).

Definition at line 183 of file regex_match.hpp.

Member Data Documentation

◆ first_

template<typename BidirIt , typename Alloc = std::allocator<sub_match<BidirIt>>>
BidirIt real::compat::match_results< BidirIt, Alloc >::first_ {}
private

Start of the searched sequence.

Definition at line 289 of file regex_match.hpp.

◆ groups_

template<typename BidirIt , typename Alloc = std::allocator<sub_match<BidirIt>>>
std::vector<value_type, Alloc> real::compat::match_results< BidirIt, Alloc >::groups_
private

Group sub-matches (0 = whole match).

Definition at line 291 of file regex_match.hpp.

◆ last_

template<typename BidirIt , typename Alloc = std::allocator<sub_match<BidirIt>>>
BidirIt real::compat::match_results< BidirIt, Alloc >::last_ {}
private

End of the searched sequence.

Definition at line 290 of file regex_match.hpp.

◆ prefix_

template<typename BidirIt , typename Alloc = std::allocator<sub_match<BidirIt>>>
value_type real::compat::match_results< BidirIt, Alloc >::prefix_ {}
private

Unmatched prefix.

Definition at line 292 of file regex_match.hpp.

◆ ready_

template<typename BidirIt , typename Alloc = std::allocator<sub_match<BidirIt>>>
bool real::compat::match_results< BidirIt, Alloc >::ready_ {false}
private

Whether a match is stored.

Definition at line 295 of file regex_match.hpp.

◆ suffix_

template<typename BidirIt , typename Alloc = std::allocator<sub_match<BidirIt>>>
value_type real::compat::match_results< BidirIt, Alloc >::suffix_ {}
private

Unmatched suffix.

Definition at line 293 of file regex_match.hpp.

◆ unmatched_

template<typename BidirIt , typename Alloc = std::allocator<sub_match<BidirIt>>>
value_type real::compat::match_results< BidirIt, Alloc >::unmatched_ {}
private

Sentinel for out-of-range operator[] (anchored at last_).

Definition at line 294 of file regex_match.hpp.


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