std::sub_match< _BiIter > Class Template Reference
Regular Expressions

`#include <regex>`

## Public Types

typedef __iter_traits::difference_type | difference_type
typedef _BiIter | iterator
typedef basic_string< value_type > | string_type
typedef __iter_traits::value_type | value_type

## Public Member Functions

int | compare (const sub_match &__s) const
difference_type | length () const noexcept
| operator string_type () const
string_type | str () const
void | swap (sub_match &__s) noexcept(__is_nothrow_swappable< _BiIter >::value)
int | compare (const string_type &__s) const
int | compare (const value_type *__s) const

## Public Attributes

iterator | first
bool | matched
iterator | second

## Related Symbols

(Note that these are not member symbols.)
template<typename _BiIter>
bool | operator== (const sub_match< _BiIter > &__lhs, const sub_match< _BiIter > &__rhs)
template<typename _BiIter>
auto | operator<=> (const sub_match< _BiIter > &__lhs, const sub_match< _BiIter > &__rhs) noexcept(__detail::__is_contiguous_iter< _BiIter >::value)
template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
bool | operator== (const sub_match< _Bi_iter > &__lhs, const __sub_match_string< _Bi_iter, _Ch_traits, _Ch_alloc > &__rhs)
template<typename _Bi_iter, typename _Ch_traits, typename _Alloc>
auto | operator<=> (const sub_match< _Bi_iter > &__lhs, const __sub_match_string< _Bi_iter, _Ch_traits, _Alloc > &__rhs) noexcept(__detail::__is_contiguous_iter< _Bi_iter >::value)
template<typename _Bi_iter>
bool | operator== (const sub_match< _Bi_iter > &__lhs, typename iterator_traits< _Bi_iter >::value_type const *__rhs)
template<typename _Bi_iter>
auto | operator<=> (const sub_match< _Bi_iter > &__lhs, typename iterator_traits< _Bi_iter >::value_type const *__rhs) noexcept(__detail::__is_contiguous_iter< _Bi_iter >::value)
template<typename _Bi_iter>
bool | operator== (const sub_match< _Bi_iter > &__lhs, typename iterator_traits< _Bi_iter >::value_type const &__rhs)
template<typename _Bi_iter>
auto | operator<=> (const sub_match< _Bi_iter > &__lhs, typename iterator_traits< _Bi_iter >::value_type const &__rhs) noexcept(__detail::__is_contiguous_iter< _Bi_iter >::value)
template<typename _Ch_type, typename _Ch_traits, typename _Bi_iter>
basic_ostream< _Ch_type, _Ch_traits > & | operator<< (basic_ostream< _Ch_type, _Ch_traits > &__os, const sub_match< _Bi_iter > &__m)

## Detailed Description

template<typename _BiIter>
class std::sub_match< _BiIter >

A sequence of characters matched by a particular marked sub-expression.

An object of this class is essentially a pair of iterators marking a matched subexpression within a regular expression pattern match. Such objects can be converted to and compared with std::basic_string objects of the same character type as the pattern matched by the regular expression.

A sub_match<Iter> has a public base class of type pair<Iter, Iter>, so inherits pair's data members named first and second. The iterators that make up the pair are the usual half-open interval referencing the actual original pattern matched.

Since
  C++11

Definition at line 920 of file regex.h.

## Member Typedef Documentation

## difference_type

template<typename _BiIter>

typedef __iter_traits::difference_type std::sub_match< _BiIter >::difference_type

Definition at line 929 of file regex.h.

## iterator

template<typename _BiIter>

typedef _BiIter std::sub_match< _BiIter >::iterator

Definition at line 930 of file regex.h.

## string_type

template<typename _BiIter>

typedef basic_string<value_type> std::sub_match< _BiIter >::string_type

Definition at line 931 of file regex.h.

## value_type

template<typename _BiIter>

typedef __iter_traits::value_type std::sub_match< _BiIter >::value_type

Definition at line 928 of file regex.h.

## Constructor & Destructor Documentation

## sub_match()

template<typename _BiIter>

std::sub_match< _BiIter >::sub_match | ( |  | ) |

inline constexpr noexcept

Definition at line 937 of file regex.h.

## Member Function Documentation

## compare() [1/3]

template<typename _BiIter>

int std::sub_match< _BiIter >::compare | ( | const string_type & | __s | ) | const

inline

Compares this sub_match to a string.

Parameters

  __s | A string to compare to this sub_match.

Return values

  negative | This matched sequence will collate before __s.
  zero | This matched sequence is equivalent to __s.
  positive | This matched sequence will collate after __s.

Definition at line 994 of file regex.h.

## compare() [2/3]

template<typename _BiIter>

int std::sub_match< _BiIter >::compare | ( | const sub_match< _BiIter > & | __s | ) | const

inline

Compares this and another matched sequence.

Parameters

  __s | Another matched sequence to compare to this one.

Return values

  negative | This matched sequence will collate before __s.
  zero | This matched sequence is equivalent to __s.
  positive | This matched sequence will collate after __s.

Definition at line 980 of file regex.h.

Referenced by std::sub_match< const char * >::operator==(), and std::sub_match< const char * >::operator==().

## compare() [3/3]

template<typename _BiIter>

int std::sub_match< _BiIter >::compare | ( | const value_type * | __s | ) | const

inline

Compares this sub_match to a string.

Parameters

  __s | A string to compare to this sub_match.

Return values

  negative | This matched sequence will collate before __s.
  zero | This matched sequence is equivalent to __s.
  positive | This matched sequence will collate after __s.

Definition at line 998 of file regex.h.

## length()

template<typename _BiIter>

difference_type std::sub_match< _BiIter >::length | ( |  | ) | const

inline noexcept

Gets the length of the matching sequence.

Definition at line 941 of file regex.h.

## operator string_type()

template<typename _BiIter>

std::sub_match< _BiIter >::operator string_type | ( |  | ) | const

inline

Gets the matching sequence as a string.

Returns
  the matching sequence as a string.

This is the implicit conversion operator. It is identical to the str() member function except that it will want to pop up in unexpected places and cause a great deal of confusion and cursing from the unwary.

Definition at line 954 of file regex.h.

## str()

template<typename _BiIter>

string_type std::sub_match< _BiIter >::str | ( |  | ) | const

inline

Gets the matching sequence as a string.

Returns
  the matching sequence as a string.

Definition at line 963 of file regex.h.

Referenced by std::sub_match< const char * >::operator string_type().

## swap()

template<typename _BiIter>

void std::sub_match< _BiIter >::swap | ( | sub_match< _BiIter > & | __s | ) |

inline noexcept

Swap the values of two sub_match objects.

Definition at line 1013 of file regex.h.

## Member Data Documentation

## first

template<typename _BiIter>

iterator std::sub_match< _BiIter >::first

Definition at line 933 of file regex.h.

## matched

template<typename _BiIter>

bool std::sub_match< _BiIter >::matched

Definition at line 935 of file regex.h.

## second

template<typename _BiIter>

iterator std::sub_match< _BiIter >::second

Definition at line 933 of file regex.h.

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

- regex.h