STD::MATCH_RESULTS(3cxx)

πŸ’– NAME πŸ’–

std::match_results< _Bi_iter, _Alloc > β€” bestie, this is the place where the results of a match or search operation live. Like, the receipts of your regex. ✨

(also hi, this is std::match_resu..._iter, _Alloc >(3cxx), the manual page, coming at you in two parts 🫢)


🌈 SYNOPSIS 🌈

#include <regex>

Inherits std::vector< _Tp, _Alloc >. No cap, it really does.


πŸŽ€ 28.10 Public Types πŸŽ€

  • typedef sub_match< _Bi_iter > value_type
  • typedef const value_type & const_reference
  • typedef value_type & reference
  • typedef _Base_type::const_iterator const_iterator
  • typedef const_iterator iterator
  • typedef __iter_traits::difference_type difference_type
  • typedef allocator_traits< _Alloc >::size_type size_type
  • typedef _Alloc allocator_type
  • typedef __iter_traits::value_type char_type
  • typedef std::basic_string< char_type > string_type

πŸ’… Public Member Functions πŸ’…

  • template<typename _Out_iter > _Out_iter format (_Out_iter __out, const match_results< _Bi_iter, _Alloc >::char_type *__fmt_first, const match_results< _Bi_iter, _Alloc >::char_type *__fmt_last, match_flag_type __flags) const β€” the big format function, go write your matches out somewhere πŸ”₯
  • bool ready () const noexcept β€” Indicates if the match_results is ready. the vibe check of match_results, honestly ✨

πŸ’– 28.10.1 Construction, Copying, and Destruction πŸ’–

  • match_results () β€” Constructs a default match_results container.
  • match_results (const _Alloc &__a) noexcept β€” Constructs a default match_results container.
  • match_results (const match_results &)=default β€” Copy constructs a match_results.
  • match_results (match_results &&) noexcept=default β€” Move constructs a match_results.
  • match_results & operator= (const match_results &)=default β€” Assigns rhs to *this.
  • match_results & operator= (match_results &&)=default β€” Move-assigns rhs to *this.
  • ~match_results ()=default β€” Destroys a match_results object. bye bestie πŸ‘‹
  • match_results (const match_results &__m, const _Alloc &__a) β€” Constructs a default match_results container.
  • match_results (match_results &&__m, const _Alloc &__a) noexcept(noexcept(_Base_type(std::move(__m), __a))) β€” Constructs a default match_results container.

πŸ¦‹ 28.10.2 Size πŸ¦‹

  • size_type size () const noexcept β€” Gets the number of matches and submatches.
  • size_type max_size () const noexcept β€” Gets the number of matches and submatches.
  • bool empty () const noexcept β€” Indicates if the match_results contains no results. the "nothing matched" heartbreak 😭

🌸 28.10.4 Element Access 🌸

  • difference_type length (size_type __sub=0) const β€” Gets the length of the indicated submatch.
  • difference_type position (size_type __sub=0) const β€” Gets the offset of the beginning of the indicated submatch.
  • string_type str (size_type __sub=0) const β€” Gets the match or submatch converted to a string type.
  • const_reference operator[] (size_type __sub) const β€” Gets a sub_match reference for the match or submatch.
  • const_reference prefix () const β€” Gets a sub_match representing the match prefix.
  • const_reference suffix () const β€” Gets a sub_match representing the match suffix.
  • const_iterator begin () const noexcept β€” Gets an iterator to the start of the sub_match collection.
  • const_iterator cbegin () const noexcept β€” Gets an iterator to the start of the sub_match collection.
  • const_iterator end () const noexcept β€” Gets an iterator to one-past-the-end of the collection.
  • const_iterator cend () const noexcept β€” Gets an iterator to one-past-the-end of the collection.

⭐ 28.10.5 Formatting ⭐

These functions perform formatted substitution of the matched character sequences into their target. The format specifiers and escape sequences accepted by these functions are determined by their flags parameter as documented above. iykyk πŸ‘‘

  • template<typename _Out_iter > _Out_iter format (_Out_iter __out, const char_type *__fmt_first, const char_type *__fmt_last, match_flag_type __flags=regex_constants::format_default) const
  • template<typename _Out_iter , typename _St , typename _Sa > _Out_iter format (_Out_iter __out, const basic_string< char_type, _St, _Sa > &__fmt, match_flag_type __flags=regex_constants::format_default) const
  • template<typename _St , typename _Sa > basic_string< char_type, _St, _Sa > format (const basic_string< char_type, _St, _Sa > &__fmt, match_flag_type __flags=regex_constants::format_default) const
  • string_type format (const char_type *__fmt, match_flag_type __flags=regex_constants::format_default) const

πŸ“ 28.10.6 Allocator πŸ“

  • allocator_type get_allocator () const noexcept β€” Gets a copy of the allocator.

🧚 28.10.7 Swap 🧚

  • void swap (match_results &__that) noexcept β€” Swaps the contents of two match_results.

πŸ™ˆ Private Member Functions πŸ™ˆ

  • constexpr iterator begin () noexcept
  • constexpr iterator end () noexcept
  • constexpr const_reference operator[] (size_type __n) const noexcept β€” Subscript access to the data contained in the vector.
  • constexpr reference operator[] (size_type __n) noexcept β€” Subscript access to the data contained in the vector.
  • constexpr void swap (vector &__x) noexcept β€” Swaps data with another vector.

πŸ‘‘ Friends πŸ‘‘

  • template<typename , typename , typename > class regex_iterator

(Note that these are not member symbols. not part of the inner circle, but still iconic πŸ’œ)

  • template<typename _Bi_iter , typename _Alloc > bool operator== (const match_results< _Bi_iter, _Alloc > &__m1, const match_results< _Bi_iter, _Alloc > &__m2) β€” Compares two match_results for equality.
  • template<typename _Bi_iter , typename _Alloc > void swap (match_results< _Bi_iter, _Alloc > &__lhs, match_results< _Bi_iter, _Alloc > &__rhs) noexcept β€” Swaps two match results.

✨ Detailed Description ✨

template<typename _Bi_iter, typename _Alloc = allocator<sub_match<_Bi_iter> >>
class std::match_results< _Bi_iter, _Alloc >

"The results of a match or search operation." β€” literally the whole point, bestie.

A collection of character sequences representing the result of a regular expression match. Storage for the collection is allocated and freed as necessary by the member functions of class template match_results.

This class satisfies the Sequence requirements, with the exception that only the operations defined for a const-qualified Sequence are supported. so it's like Sequenceβ„’ but lowkey const-only, don't fight it πŸ’…

The sub_match object stored at index 0 represents sub-expression 0, i.e. the whole match. In this case the sub_match member matched is always true. The sub_match object stored at index n denotes what matched the marked sub-expression n within the matched expression. If the sub-expression n participated in a regular expression match then the sub_match member matched evaluates to true, and members first and second denote the range of characters [first, second) which formed that match. Otherwise matched is false, and members first and second point to the end of the sequence that was searched.

fr fr: index 0 = the whole thing, and matched is always true there. every other index depends on whether that sub-expression actually showed up to the party πŸ™ˆ

πŸ’€ Since πŸ’€

C++11


🌺 Constructor & Destructor Documentation 🌺

template<typename _Bi_iter , typename _Alloc  =
    allocator<sub_match<_Bi_iter> >> std::match_results< _Bi_iter, _Alloc
    >::match_results () [inline]

Constructs a default match_results container.

Postcondition

size() returns 0 and str() returns an empty string. empty on purpose, main character energy πŸŽ€


template<typename _Bi_iter , typename _Alloc  =
    allocator<sub_match<_Bi_iter> >> std::match_results< _Bi_iter, _Alloc
    >::match_results (const _Alloc & __a) [inline],  [explicit],  [noexcept]

Constructs a default match_results container.

Postcondition

size() returns 0 and str() returns an empty string.


template<typename _Bi_iter , typename _Alloc  =
    allocator<sub_match<_Bi_iter> >> std::match_results< _Bi_iter, _Alloc
    >::match_results (const match_results< _Bi_iter, _Alloc > &) [default]

Copy constructs a match_results. twin behavior πŸ’–


template<typename _Bi_iter , typename _Alloc  =
    allocator<sub_match<_Bi_iter> >> std::match_results< _Bi_iter, _Alloc
    >::match_results (match_results< _Bi_iter, _Alloc > &&) [default],
[noexcept]

Move constructs a match_results. it just slides over, no drama πŸ¦‹


template<typename _Bi_iter , typename _Alloc  =
    allocator<sub_match<_Bi_iter> >> std::match_results< _Bi_iter, _Alloc
    >::~match_results () [default]

Destroys a match_results object.


template<typename _Bi_iter , typename _Alloc  =
    allocator<sub_match<_Bi_iter> >> std::match_results< _Bi_iter, _Alloc
    >::match_results (const match_results< _Bi_iter, _Alloc > & __m, const
    _Alloc & __a) [inline]

Constructs a default match_results container.

Postcondition

size() returns 0 and str() returns an empty string.


template<typename _Bi_iter , typename _Alloc  =
    allocator<sub_match<_Bi_iter> >> std::match_results< _Bi_iter, _Alloc
    >::match_results (match_results< _Bi_iter, _Alloc > && __m, const _Alloc
    & __a) [inline],  [noexcept]

Constructs a default match_results container.

Postcondition

size() returns 0 and str() returns an empty string.


πŸ’… Member Function Documentation πŸ’…

okay so bestie, this is the part where match_results actually starts doing its little dances ✨ every signature is kept exactly as it is β€” no cap, no renaming, no β€œfixing.” preconditions are called out with > so you don’t miss them, and every reference / referenced-by list is right here. let’s go πŸ’–


🌸 begin

   template<typename _Bi_iter , typename _Alloc  =
       allocator<sub_match<_Bi_iter> >> const_iterator std::match_results<
       _Bi_iter, _Alloc >::begin () const [inline],  [noexcept]

Gets an iterator to the start of the sub_match collection. literally the front door of the match list πŸšͺ✨

  • References: std::vector< _Tp, _Alloc >::begin()
  • Referenced by: std::match_results< _Bi_iter, _Alloc >::cbegin(), and std::match_results< _Bi_iter, _Alloc >::operator==()

πŸ¦‹ cbegin

   template<typename _Bi_iter , typename _Alloc  =
       allocator<sub_match<_Bi_iter> >> const_iterator std::match_results<
       _Bi_iter, _Alloc >::cbegin () const [inline],  [noexcept]

Gets an iterator to the start of the sub_match collection. same start-of-the-collection energy, const flavored πŸ’…

  • References: std::match_results< _Bi_iter, _Alloc >::begin()

πŸŽ€ cend

   template<typename _Bi_iter , typename _Alloc  =
       allocator<sub_match<_Bi_iter> >> const_iterator std::match_results<
       _Bi_iter, _Alloc >::cend () const [inline],  [noexcept]

Gets an iterator to one-past-the-end of the collection. the β€œyou’ve gone too far, bestie” marker πŸ›‘

  • References: std::match_results< _Bi_iter, _Alloc >::end()

πŸ’€ empty

   template<typename _Bi_iter , typename _Alloc  =
       allocator<sub_match<_Bi_iter> >> bool std::match_results< _Bi_iter,
       _Alloc >::empty () const [inline],  [noexcept]

Indicates if the match_results contains no results. vibe check: is the match list empty or not? πŸ‘€

Return values:

  • true β€” The match_results object is empty.
  • false β€” The match_results object is not empty.
  • Referenced by: std::match_results< _Bi_iter, _Alloc >::operator==(), std::match_results< _Bi_iter, _Alloc >::prefix(), and std::match_results< _Bi_iter, _Alloc >::suffix()

✨ end

   template<typename _Bi_iter , typename _Alloc  =
       allocator<sub_match<_Bi_iter> >> const_iterator std::match_results<
       _Bi_iter, _Alloc >::end () const [inline],  [noexcept]

Gets an iterator to one-past-the-end of the collection. it’s giving β€œthe end, periodt” 🌈

  • References: std::vector< _Tp, _Alloc >::empty(), and std::vector< _Tp, _Alloc >::end()
  • Referenced by: std::match_results< _Bi_iter, _Alloc >::cend(), and std::match_results< _Bi_iter, _Alloc >::operator==()

πŸ’« format (1 of 4)

   template<typename _Bi_iter , typename _Alloc  =
       allocator<sub_match<_Bi_iter> >> template<typename _Out_iter , typename
       _St , typename _Sa > _Out_iter std::match_results< _Bi_iter, _Alloc
       >::format (_Out_iter __out, const basic_string< char_type, _St, _Sa > &
       __fmt, match_flag_type __flags = regex_constants::format_default) const
       [inline]
Precondition: ready() == true
  • References: std::basic_string< _CharT, _Traits, _Alloc >::data(), std::match_results< _Bi_iter, _Alloc >::format(), and std::basic_string< _CharT, _Traits, _Alloc >::size()

πŸ”₯ format (2 of 4)

   template<typename _Bi_iter , typename _Alloc  =
       allocator<sub_match<_Bi_iter> >> template<typename _Out_iter > _Out_iter
       std::match_results< _Bi_iter, _Alloc >::format (_Out_iter __out, const
       char_type * __fmt_first, const char_type * __fmt_last, match_flag_type
       __flags = regex_constants::format_default) const
Precondition: ready() == true
  • Referenced by: std::match_results< _Bi_iter, _Alloc >::format(), std::match_results< _Bi_iter, _Alloc >::format(), and std::match_results< _Bi_iter, _Alloc >::format()

🌈 format (3 of 4)

   template<typename _Bi_iter , typename _Alloc  =
       allocator<sub_match<_Bi_iter> >> template<typename _St , typename _Sa >
       basic_string< char_type, _St, _Sa > std::match_results< _Bi_iter, _Alloc
       >::format (const basic_string< char_type, _St, _Sa > & __fmt,
       match_flag_type __flags = regex_constants::format_default) const
       [inline]
Precondition: ready() == true
  • References: std::back_inserter(), and std::match_results< _Bi_iter, _Alloc >::format()

πŸ“ format (4 of 4)

   template<typename _Bi_iter , typename _Alloc  =
       allocator<sub_match<_Bi_iter> >> string_type std::match_results<
       _Bi_iter, _Alloc >::format (const char_type * __fmt, match_flag_type
       __flags = regex_constants::format_default) const [inline]
Precondition: ready() == true
  • References: std::back_inserter(), and std::match_results< _Bi_iter, _Alloc >::format()

🧚 get_allocator

   template<typename _Bi_iter , typename _Alloc  =
       allocator<sub_match<_Bi_iter> >> allocator_type std::match_results<
       _Bi_iter, _Alloc >::get_allocator () const [inline],  [noexcept]

Gets a copy of the allocator. tiny little allocator souvenir 🎁

  • References: std::vector< _Tp, _Alloc >::get_allocator()

πŸ‘‘ length

   template<typename _Bi_iter , typename _Alloc  =
       allocator<sub_match<_Bi_iter> >> difference_type std::match_results<
       _Bi_iter, _Alloc >::length (size_type __sub = 0) const [inline]

Gets the length of the indicated submatch.

Parameters:

  • __sub indicates the submatch.
Precondition: ready() == true

This function returns the length of the indicated submatch, or the length of the entire match if __sub is zero (the default).


πŸ¦„ max_size

   template<typename _Bi_iter , typename _Alloc  =
       allocator<sub_match<_Bi_iter> >> size_type std::match_results< _Bi_iter,
       _Alloc >::max_size () const [inline],  [noexcept]

Gets the number of matches and submatches. The number of matches for a given regular expression will be either 0 if there was no match or mark_count() + 1 if a match was successful. Some matches may be empty.

Returns:

  • the number of matches found.

πŸ’œ operator= (copy)

   template<typename _Bi_iter , typename _Alloc  =
       allocator<sub_match<_Bi_iter> >> match_results & std::match_results<
       _Bi_iter, _Alloc >::operator= (const match_results< _Bi_iter, _Alloc >
       &) [default]

Assigns rhs to *this. classic copy-assign behavior, defaulted and chill 🫢


πŸ’œ operator= (move)

   template<typename _Bi_iter , typename _Alloc  =
       allocator<sub_match<_Bi_iter> >> match_results & std::match_results<
       _Bi_iter, _Alloc >::operator= (match_results< _Bi_iter, _Alloc > &&)
       [default]

Move-assigns rhs to *this. same assignment energy, but it’s moving, periodt πŸ’¨


🌟 operator[]

   template<typename _Bi_iter , typename _Alloc  =
       allocator<sub_match<_Bi_iter> >> const_reference std::match_results<
       _Bi_iter, _Alloc >::operator[] (size_type __sub) const [inline]

Gets a sub_match reference for the match or submatch.

Parameters:

  • __sub indicates the submatch.
Precondition: ready() == true

This function gets a reference to the indicated submatch, or the entire match if __sub is zero.

If __sub >= size() then this function returns a sub_match with a special value indicating no submatch.

  • References: std::match_results< _Bi_iter, _Alloc >::ready(), and std::match_results< _Bi_iter, _Alloc >::size()

🎯 position

   template<typename _Bi_iter , typename _Alloc  =
       allocator<sub_match<_Bi_iter> >> difference_type std::match_results<
       _Bi_iter, _Alloc >::position (size_type __sub = 0) const [inline]

Gets the offset of the beginning of the indicated submatch.

Parameters:

  • __sub indicates the submatch.
Precondition: ready() == true

This function returns the offset from the beginning of the target sequence to the beginning of the submatch, unless the value of __sub is zero (the default), in which case this function returns the offset from the beginning of the target sequence to the beginning of the match.

  • References: std::distance()

🌸 prefix

   template<typename _Bi_iter , typename _Alloc  =
       allocator<sub_match<_Bi_iter> >> const_reference std::match_results<
       _Bi_iter, _Alloc >::prefix () const [inline]

Gets a sub_match representing the match prefix.

Precondition: ready() == true

This function gets a reference to a sub_match object representing the part of the target range between the start of the target range and the start of the match.

  • References: std::match_results< _Bi_iter, _Alloc >::empty(), and std::match_results< _Bi_iter, _Alloc >::ready()
  • Referenced by: std::match_results< _Bi_iter, _Alloc >::operator==()

βœ… ready

   template<typename _Bi_iter , typename _Alloc  =
       allocator<sub_match<_Bi_iter> >> bool std::match_results< _Bi_iter,
       _Alloc >::ready () const [inline],  [noexcept]

Indicates if the match_results is ready. like, is the result state fully established or are we still waiting? ⏳

Return values:

  • true β€” The object has a fully-established result state.
  • false β€” The object is not ready.
  • Referenced by: std::match_results< _Bi_iter, _Alloc >::operator==(), std::match_results< _Bi_iter, _Alloc >::operator[](), std::match_results< _Bi_iter, _Alloc >::prefix(), and std::match_results< _Bi_iter, _Alloc >::suffix()

πŸŽ€ size

   template<typename _Bi_iter , typename _Alloc  =
       allocator<sub_match<_Bi_iter> >> size_type std::match_results< _Bi_iter,
       _Alloc >::size () const [inline],  [noexcept]

Gets the number of matches and submatches. The number of matches for a given regular expression will be either 0 if there was no match or mark_count() + 1 if a match was successful. Some matches may be empty.

Returns:

  • the number of matches found.
  • Referenced by: std::match_results< _Bi_iter, _Alloc >::operator==(), and std::match_results< _Bi_iter, _Alloc >::operator[]()

πŸ¦‹ str

   template<typename _Bi_iter , typename _Alloc  =
       allocator<sub_match<_Bi_iter> >> string_type std::match_results<
       _Bi_iter, _Alloc >::str (size_type __sub = 0) const [inline]

Gets the match or submatch converted to a string type.

Parameters:

  • __sub indicates the submatch.
Precondition: ready() == true

This function gets the submatch (or match, if __sub is zero) extracted from the target range and converted to the associated string type.


🌈 suffix

   template<typename _Bi_iter , typename _Alloc  =
       allocator<sub_match<_Bi_iter> >> const_reference std::match_results<
       _Bi_iter, _Alloc >::suffix () const [inline]

Gets a sub_match representing the match suffix.

Precondition: ready() == true

This function gets a reference to a sub_match object representing the part of the target range between the end of the match and the end of the target range.

  • References: std::match_results< _Bi_iter, _Alloc >::empty(), and std::match_results< _Bi_iter, _Alloc >::ready()
  • Referenced by: std::match_results< _Bi_iter, _Alloc >::operator==()

πŸ’… swap

   template<typename _Bi_iter , typename _Alloc  =
       allocator<sub_match<_Bi_iter> >> void std::match_results< _Bi_iter,
       _Alloc >::swap (match_results< _Bi_iter, _Alloc > & __that) [inline],
       [noexcept]

Swaps the contents of two match_results. trading places, but make it regex βœ¨πŸ”

  • References: std::match_results< _Bi_iter, _Alloc >::swap(), and std::vector< _Tp, _Alloc >::swap()
  • Referenced by: std::match_results< _Bi_iter, _Alloc >::swap()

πŸ‘‘ Author πŸ‘‘

Generated automatically by Doxygen for libstdc++ from the source code.


and that’s the whole page, bestie πŸ«ΆπŸ’– huge thanks to the libstdc++ source/version and date sitting pretty in the footer β€” couldn’t have done this little tour without them. mwah! πŸ’‹βœ¨

πŸ“¦ where this page comes from