STD::MATCH_RESULTS(3)
π std::match_results< _Bi_iter, _Alloc > π
Library Functions Manual Β· section 3 Β· bestie we are SO deep in the C++ regex mines rn
β¨ NAME β¨
std::match_results< _Bi_iter, _Alloc > β the receipts of a match or search operation. like, literally the results. π§Ύβ¨
πΈ SYNOPSIS πΈ
#include <regex>
Inherits std::vector< _Tp, _Alloc >. yeah she's a vector girlie at heart π
π Public Types
28.10 Public Types
typedef sub_match< _Bi_iter > value_typetypedef const value_type & const_referencetypedef value_type & referencetypedef _Base_type::const_iterator const_iteratortypedef const_iterator iteratortypedef __iter_traits::difference_type difference_typetypedef allocator_traits< _Alloc >::size_type size_typetypedef _Alloc allocator_typetypedef __iter_traits::value_type char_typetypedef 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β formats stuff, we'll get into itbool ready () const noexceptβ Indicates if thematch_resultsis ready. π
π 28.10.1 Construction, Copying, and Destruction
match_results ()β Constructs a defaultmatch_resultscontainer.match_results (const _Alloc &__a) noexceptβ Constructs a defaultmatch_resultscontainer.match_results (const match_results &)=defaultβ Copy constructs amatch_results.match_results (match_results &&) noexcept=defaultβ Move constructs amatch_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 amatch_resultsobject. rip bestie π«‘match_results (const match_results &__m, const _Alloc &__a)β Constructs a defaultmatch_resultscontainer.match_results (match_results &&__m, const _Alloc &__a) noexcept(noexcept(_Base_type(std::move(__m), __a)))β Constructs a defaultmatch_resultscontainer.
πΌ 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 thematch_resultscontains no results. the "is the fridge empty" check fr fr
π 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 asub_matchreference for the match or submatch.const_reference prefix () constβ Gets asub_matchrepresenting the match prefix.const_reference suffix () constβ Gets asub_matchrepresenting the match suffix.const_iterator begin () const noexceptβ Gets an iterator to the start of thesub_matchcollection.const_iterator cbegin () const noexceptβ Gets an iterator to the start of thesub_matchcollection.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. π
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) consttemplate<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) consttemplate<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) conststring_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 twomatch_results.
π Private Member Functions
constexpr iterator begin () noexceptconstexpr iterator end () noexceptconstexpr 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
π Related Symbols
(Note that these are not member symbols.)
template<typename _Bi_iter, typename _Alloc> bool operator== (const match_results< _Bi_iter, _Alloc > &__m1, const match_results< _Bi_iter, _Alloc > &__m2)β Compares twomatch_resultsfor 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.
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 no, you can't go editing her, she's read-only energy π )
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.
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.
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.
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.
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 bestie, this is the part where we meet the actual member functions. no cap, they're all here, and they're all giving useful. let's go. π
πΈ begin() β start of the sub_match collection πΈ
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. that's it, that's the vibe. β¨
Referenced by std::match_results< _BidirectionalIterator, polymorphic_allocator< sub_match< _BidirectionalIterator > > >< const char * >::cbegin(), and std::match_results< _BidirectionalIterator, polymorphic_allocator< sub_match< _BidirectionalIterator > > >< const char * >::operator==().
πΈ cbegin() β const start, same energy πΈ
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. literally the same description as begin(), because const-correctness is iconic. π
πΈ cend() β const one-past-the-end πΈ
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 end, but make it const. periodt. β¨
πΈ empty() β is it empty, bestie? πΈ
template<typename _Bi_iter, typename _Alloc = allocator<sub_match<_Bi_iter>
>> bool std::match_results< _Bi_iter, _Alloc >::empty () const [inline],
[nodiscard], [noexcept]
Indicates if the match_results contains no results.
Return values:
trueThematch_resultsobject is empty.falseThematch_resultsobject is not empty.
Referenced by std::match_results< _BidirectionalIterator, polymorphic_allocator< sub_match< _BidirectionalIterator > > >< const char * >::operator==(), std::match_results< _BidirectionalIterator, polymorphic_allocator< sub_match< _BidirectionalIterator > > >< const char * >::prefix(), and std::match_results< _BidirectionalIterator, polymorphic_allocator< sub_match< _BidirectionalIterator > > >< const char * >::suffix().
πΈ end() β one-past-the-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. classic end iterator, no notes. β¨
Referenced by std::match_results< _BidirectionalIterator, polymorphic_allocator< sub_match< _BidirectionalIterator > > >< const char * >::cend(), and std::match_results< _BidirectionalIterator, polymorphic_allocator< sub_match< _BidirectionalIterator > > >< const char * >::operator==().
πΈ format() β output iterator + string format πΈ
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.
That's the whole tea for this overload. no extra description, just vibes and a precondition. π
πΈ format() β output iterator + [first, last) format πΈ
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< _BidirectionalIterator, polymorphic_allocator< sub_match< _BidirectionalIterator > > >< const char * >::format(), std::match_results< _BidirectionalIterator, polymorphic_allocator< sub_match< _BidirectionalIterator > > >< const char * >::format(), and std::match_results< _BidirectionalIterator, polymorphic_allocator< sub_match< _BidirectionalIterator > > >< const char * >::format().
yes, three times. they said what they said. keep it exact. π
πΈ format() β string format πΈ
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.
πΈ format() β C-string format πΈ
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.
πΈ get_allocator() β copy of the 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. that's it, that's the whole function. π
πΈ length() β how long is that submatch? πΈ
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() β number of matches and submatches πΈ
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 assignment πΈ
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. defaulted, so you know it's clean. π
πΈ operator= β move assignment πΈ
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. defaulted again. slay. β¨
πΈ operator[] β get a sub_match reference πΈ
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. π
πΈ position() β offset of the beginning πΈ
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. π
πΈ prefix() β the match 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.
Referenced by std::match_results< _BidirectionalIterator, polymorphic_allocator< sub_match< _BidirectionalIterator > > >< const char * >::operator==().
πΈ ready() β is it ready though? πΈ
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.
Return values:
trueThe object has a fully-established result state.falseThe object is not ready.
Referenced by std::match_results< _BidirectionalIterator, polymorphic_allocator< sub_match< _BidirectionalIterator > > >< const char * >::operator==(), std::match_results< _BidirectionalIterator, polymorphic_allocator< sub_match< _BidirectionalIterator > > >< const char * >::operator[](), std::match_results< _BidirectionalIterator, polymorphic_allocator< sub_match< _BidirectionalIterator > > >< const char * >::prefix(), and std::match_results< _BidirectionalIterator, polymorphic_allocator< sub_match< _BidirectionalIterator > > >< const char * >::suffix().
πΈ size() β number of matches and submatches πΈ
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< _BidirectionalIterator, polymorphic_allocator< sub_match< _BidirectionalIterator > > >< const char * >::operator==(), and std::match_results< _BidirectionalIterator, polymorphic_allocator< sub_match< _BidirectionalIterator > > >< const char * >::operator[]().
πΈ str() β match or submatch as a string πΈ
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() β the match 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.
Referenced by std::match_results< _BidirectionalIterator, polymorphic_allocator< sub_match< _BidirectionalIterator > > >< const char * >::operator==().
πΈ swap() β swap two match_results πΈ
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.
Referenced by std::match_results< _BidirectionalIterator, polymorphic_allocator< sub_match< _BidirectionalIterator > > >< const char * >::swap().
π Author π
Generated automatically by Doxygen for libstdc++ from the source code.
and that's the whole page, bestie. the footer is giving source/version: libstdc++ and page title: std::match..., _Alloc >(3). the date? the footer we got didn't hand us one, so if your local manpage has a date, it's iconic. no cap. πβ¨π¦
π¦ where this page comes from
- arch rolling: gcc 16.2.1+r23+gd564253eb6c8-1 Β· GPL-3.0-or-later WITH GCC-exception-3.1 AND GFDL-1.3-or-later
- fedora 44: libstdc++-docs 16.2.1-2.fc44
- fedora 44: libstdc++-docs 16.2.1-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms