STD::SUB_MATCH(3cxx)

🌸 NAME 🌸

std::sub_match< _BiIter > β€” bestie, this is the libstdc++ manual page for that regex matched-subexpression type. It’s a 3cxx page, and the manual name is folded up here right at the top like a little name tag πŸ’….

πŸŽ€ SYNOPSIS πŸŽ€

#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 β€” compares this matched sequence to another matched sequence.
  • difference_type length () const noexcept β€” gets the length of the matching sequence.
  • operator string_type () const β€” gets the matching sequence as a string.
  • string_type str () const β€” gets the matching sequence as a string.
  • void swap (sub_match &__s) noexcept(__is_nothrow_swappable< _BiIter >::value) β€” swaps the values of two sub_match objects.
  • int compare (const string_type &__s) const β€” compares this sub_match to a string.
  • int compare (const value_type *__s) const β€” compares this sub_match to a string.

tiny formatting note: the manpage tucks those last two compare overloads right under swap; they’re still here, in the exact same order, just flattened so your eyes don’t have to do parkour 🫢.

πŸ¦‹ Public Attributes πŸ¦‹

  • iterator first
  • bool matched
  • iterator second

Note: these are not member symbols, bestie.

  • template<typename _BiIter > bool operator== (const sub_match< _BiIter > &__lhs, const sub_match< _BiIter > &__rhs) β€” tests the equivalence of two regular expression submatches.
  • template<typename _BiIter > auto operator (const sub_match< _BiIter > &__lhs, const sub_match< _BiIter > &__rhs) noexcept(__detail::__is_contiguous_iter< _BiIter >::value) β€” three-way comparison of two regular expression submatches.
  • 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) β€” tests the equivalence of a regular expression submatch and a string.
  • 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) β€” three-way comparison of a regular expression submatch and a string.
  • template<typename _Bi_iter > bool operator== (const sub_match< _Bi_iter > &__lhs, typename iterator_traits< _Bi_iter >::value_type const *__rhs) β€” tests the equivalence of a regular expression submatch and a C string.
  • 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) β€” three-way comparison of a regular expression submatch and a C string.
  • template<typename _Bi_iter > bool operator== (const sub_match< _Bi_iter > &__lhs, typename iterator_traits< _Bi_iter >::value_type const &__rhs) β€” tests the equivalence of a regular expression submatch and a character.
  • 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) β€” three-way comparison of a regular expression submatch and a character.
  • 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) β€” inserts a matched string into an output stream.

πŸ’– Detailed Description πŸ’–

template<typename _BiIter>
    class std::sub_match< _BiIter >"A sequence of characters matched by a
    particular marked sub-expression.

yes, bestie, that stray " is literally in the manpage β€” I’m not fixing it, I’m respecting the source πŸ’….

Think of an object of this class as basically a pair of iterators marking a matched subexpression inside a regular expression pattern match. These objects can be converted to and compared with std::basic_string objects, as long as the character type is the same one used by the pattern matched by the regular expression.

A sub_match<Iter> has a public base class of type pair<Iter, Iter>, so it 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

🧚 Member Function Documentation 🧚

πŸ“ compare (const string_type & __s) const [inline]

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.

πŸ“ compare (const sub_match< _BiIter > & __s) const [inline]

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.

Referenced by std::sub_match< _BiIter >::operator==(), and std::sub_match< _BiIter >::operator==().


πŸ“ compare (const value_type * __s) const [inline]

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.

πŸ¦‹ length () const [inline], [noexcept]

template<typename _BiIter > difference_type std::sub_match< _BiIter >::length () const [inline],  [noexcept]

Gets the length of the matching sequence.

References std::distance().


πŸ¦‹ operator string_type () const [inline]

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.
⚠️ She’s the implicit conversion operator, bestie. She is identical to the str() member function except that she will want to pop up in unexpected places and cause a great deal of confusion and cursing from the unwary. You’ve been warned πŸ’€.

References std::sub_match< _BiIter >::str().


πŸ¦‹ str () const [inline]

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.

Referenced by std::sub_match< _BiIter >::operator string_type().


🌈 swap (sub_match< _BiIter > & __s) [inline], [noexcept]

template<typename _BiIter > void std::sub_match< _BiIter >::swap (sub_match< _BiIter > & __s) [inline],  [noexcept]

Swap the values of two sub_match objects.

References std::pair< _T1, _T2 >::swap().

πŸ‘‘ Author πŸ‘‘

Generated automatically by Doxygen for libstdc++ from the source code. (Yes, our girl was literally generated by Doxygen β€” no cap.)


okay bestie, that’s the whole page: source/version is libstdc++, and the footer doesn’t give a date on this one, so I’m not inventing one. The manual name and 3cxx are folded up top, the vibes are immaculate, and the facts are all still here. Periodt. πŸ’…βœ¨πŸŽ€πŸ«Ά

πŸ“¦ where this page comes from