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

A matched sub-expression: a [first, second) range into the searched sequence. More...

#include <regex_match.hpp>

Public Types

using iterator = BidirIt
 The underlying iterator.
 
using value_type = typename std::iterator_traits< BidirIt >::value_type
 The character type.
 
using difference_type = typename std::iterator_traits< BidirIt >::difference_type
 Distance type.
 
using string_type = std::basic_string< value_type >
 The owning string type.
 

Public Member Functions

difference_type length () const
 Length of the sub-match (0 if it did not participate).
 
string_type str () const
 The matched text as an owned string (empty if it did not participate).
 
 operator string_type () const
 Implicit conversion to the owned string (std::sub_match parity).
 
std::basic_string_view< value_typeview () const
 A non-owning view of the matched text. REAL's addition; std::sub_match has no such member.
 
int compare (const string_type &other) const
 Three-way length/lexicographic comparison against a string (std::sub_match::compare).
 
int compare (const sub_match &other) const
 Three-way comparison against another sub-match, by matched text.
 

Public Attributes

BidirIt first {}
 Start of the sub-match.
 
BidirIt second {}
 One past the end of the sub-match.
 
bool matched {false}
 Whether this sub-expression participated.
 

Detailed Description

template<typename BidirIt>
class real::compat::sub_match< BidirIt >

A matched sub-expression: a [first, second) range into the searched sequence.

Contiguous iterators only — sub_match is built from byte offsets, which requires the underlying storage to be contiguous (a std::deque::iterator is random-access but not contiguous, so it is rejected).

Template Parameters
BidirItA contiguous iterator into the searched sequence.

Member Function Documentation

◆ compare() [1/2]

template<typename BidirIt >
int real::compat::sub_match< BidirIt >::compare ( const string_type other) const
inline

Three-way length/lexicographic comparison against a string (std::sub_match::compare).

Parameters
[in]otherThe string to compare against.
Returns
Negative, zero or positive as str() orders before, equal to, or after other.

◆ compare() [2/2]

template<typename BidirIt >
int real::compat::sub_match< BidirIt >::compare ( const sub_match< BidirIt > &  other) const
inline

Three-way comparison against another sub-match, by matched text.

Parameters
[in]otherThe sub-match to compare against.
Returns
Negative, zero or positive as str() orders before, equal to, or after other.str().

◆ length()

template<typename BidirIt >
difference_type real::compat::sub_match< BidirIt >::length ( ) const
inline

Length of the sub-match (0 if it did not participate).

Returns
second - first, or 0 when matched is false.

◆ str()

template<typename BidirIt >
string_type real::compat::sub_match< BidirIt >::str ( ) const
inline

The matched text as an owned string (empty if it did not participate).

Returns
A copy of [first, second), or an empty string when matched is false.

◆ view()

template<typename BidirIt >
std::basic_string_view< value_type > real::compat::sub_match< BidirIt >::view ( ) const
inline

A non-owning view of the matched text. REAL's addition; std::sub_match has no such member.

Returns
A view over [first, second), or an empty view when matched is false.

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