std::match_results< _Bi_iter, _Alloc > - The results of a match or search operation.
Contents
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(constmatch_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(constmatch_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.
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.
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
Member Function Documentation
template<typename_Bi_iter,typename_Alloc=allocator<sub_match<_Bi_iter>>>const_iteratorstd::match_results<_Bi_iter,_Alloc>::begin()const[inline],[noexcept]
Gets an iterator to the start of the sub_match collection.
Referenced by std::match_results<_Bi_iter,_Alloc>::cbegin().
template<typename_Bi_iter,typename_Alloc=allocator<sub_match<_Bi_iter>>>const_iteratorstd::match_results<_Bi_iter,_Alloc>::cbegin()const[inline],[noexcept]
Gets an iterator to the start of the sub_match collection.
References std::match_results<_Bi_iter,_Alloc>::begin().
template<typename_Bi_iter,typename_Alloc=allocator<sub_match<_Bi_iter>>>const_iteratorstd::match_results<_Bi_iter,_Alloc>::cend()const[inline],[noexcept]
Gets an iterator to one-past-the-end of the collection.
References std::match_results<_Bi_iter,_Alloc>::end().
template<typename_Bi_iter,typename_Alloc=allocator<sub_match<_Bi_iter>>>boolstd::match_results<_Bi_iter,_Alloc>::empty()const[inline],[noexcept]
Indicates if the match_results contains no results.
Returnvaluestrue The match_results object is empty.
false The match_results object is not empty.
Referenced by std::match_results<_Bi_iter,_Alloc>::prefix(), and std::match_results<_Bi_iter,_Alloc>::suffix().
template<typename_Bi_iter,typename_Alloc=allocator<sub_match<_Bi_iter>>>const_iteratorstd::match_results<_Bi_iter,_Alloc>::end()const[inline],[noexcept]
Gets an iterator to one-past-the-end of the collection.
Referenced by std::match_results<_Bi_iter,_Alloc>::cend().
template<typename_Bi_iter,typename_Alloc=allocator<sub_match<_Bi_iter>>>template<typename_Out_iter,typename_St,typename_Sa>_Out_iterstd::match_results<_Bi_iter,_Alloc>::format(_Out_iter__out,constbasic_string<char_type,_St,_Sa>&__fmt,match_flag_type__flags=regex_constants::format_default)const[inline]Precondition
ready() == true
References std::match_results<_Bi_iter,_Alloc>::format().
template<typename_Bi_iter,typename_Alloc=allocator<sub_match<_Bi_iter>>>template<typename_Out_iter>_Out_iterstd::match_results<_Bi_iter,_Alloc>::format(_Out_iter__out,constchar_type*__fmt_first,constchar_type*__fmt_last,match_flag_type__flags=regex_constants::format_default)constPrecondition
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().
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(constbasic_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().
template<typename_Bi_iter,typename_Alloc=allocator<sub_match<_Bi_iter>>>string_typestd::match_results<_Bi_iter,_Alloc>::format(constchar_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().
template<typename_Bi_iter,typename_Alloc=allocator<sub_match<_Bi_iter>>>allocator_typestd::match_results<_Bi_iter,_Alloc>::get_allocator()const[inline],[noexcept]
Gets a copy of the allocator.
template<typename_Bi_iter,typename_Alloc=allocator<sub_match<_Bi_iter>>>difference_typestd::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).
template<typename_Bi_iter,typename_Alloc=allocator<sub_match<_Bi_iter>>>size_typestd::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.
template<typename_Bi_iter,typename_Alloc=allocator<sub_match<_Bi_iter>>>match_results&std::match_results<_Bi_iter,_Alloc>::operator=(constmatch_results<_Bi_iter,_Alloc>&)[default]
Assigns rhs to *this.
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.
template<typename_Bi_iter,typename_Alloc=allocator<sub_match<_Bi_iter>>>const_referencestd::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().
template<typename_Bi_iter,typename_Alloc=allocator<sub_match<_Bi_iter>>>difference_typestd::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().
template<typename_Bi_iter,typename_Alloc=allocator<sub_match<_Bi_iter>>>const_referencestd::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().
template<typename_Bi_iter,typename_Alloc=allocator<sub_match<_Bi_iter>>>boolstd::match_results<_Bi_iter,_Alloc>::ready()const[inline],[noexcept]
Indicates if the match_results is ready.
Returnvaluestrue 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>::prefix(), and std::match_results<_Bi_iter,_Alloc>::suffix().
template<typename_Bi_iter,typename_Alloc=allocator<sub_match<_Bi_iter>>>size_typestd::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[]().
template<typename_Bi_iter,typename_Alloc=allocator<sub_match<_Bi_iter>>>string_typestd::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.
template<typename_Bi_iter,typename_Alloc=allocator<sub_match<_Bi_iter>>>const_referencestd::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().
template<typename_Bi_iter,typename_Alloc=allocator<sub_match<_Bi_iter>>>voidstd::match_results<_Bi_iter,_Alloc>::swap(match_results<_Bi_iter,_Alloc>&__that)[inline],[noexcept]
Swaps the contents of two match_results.
References std::swap(), and std::match_results<_Bi_iter,_Alloc>::swap().
Referenced by std::match_results<_Bi_iter,_Alloc>::swap().
Name
std::match_results< _Bi_iter, _Alloc > - The results of a match or search operation.
Synopsis
#include <regex>
Inherits std::vector<_Tp,_Alloc>.
PublicTypes28.10PublicTypestypedefsub_match< _Bi_iter > value_typetypedef const value_type & const_referencetypedefvalue_type & referencetypedef _Base_type::const_iterator const_iteratortypedef const_iterator iteratortypedef __iter_traits::difference_type difference_typetypedefallocator_traits< _Alloc >::size_type size_typetypedef _Alloc allocator_typetypedef __iter_traits::value_type char_typetypedefstd::basic_string< char_type > string_typePublicMemberFunctions
template<typename_Out_iter > _Out_iterformat (_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
bool ready () const noexcept
Indicates if the match_results is ready.
28.10.1Construction,Copying,andDestructionmatch_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.
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.2Size
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.
28.10.4ElementAccess
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_typestr (size_type __sub=0) const
Gets the match or submatch converted to a string type.
const_referenceoperator[] (size_type __sub) const
Gets a sub_match reference for the match or submatch.
const_referenceprefix () const
Gets a sub_match representing the match prefix.
const_referencesuffix () 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.5Formatting
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_iterformat (_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_iterformat (_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_typeformat (const char_type *__fmt, match_flag_type __flags=regex_constants::format_default)
const
28.10.6Allocator
allocator_type get_allocator () const noexcept
Gets a copy of the allocator.
28.10.7Swapvoidswap (match_results &__that) noexcept
Swaps the contents of two match_results.
PrivateMemberFunctions
constexpr iterator begin () noexcept
constexpr iterator end () noexcept
constexpr const_referenceoperator[] (size_type __n) const noexcept
Subscript access to the data contained in the vector.
constexpr referenceoperator[] (size_type __n) noexcept
Subscript access to the data contained in the vector.
constexpr voidswap (vector &__x) noexcept
Swaps data with another vector.
Friends
template<typename , typename , typename > classregex_iteratorRelatedSymbols
(Note that these are not member symbols.)
template<typename _Bi_iter , class _Alloc > bool operator!= (const match_results< _Bi_iter, _Alloc >
&__m1, const match_results< _Bi_iter, _Alloc > &__m2)
Compares two match_results for inequality.
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 > voidswap (match_results< _Bi_iter, _Alloc > &__lhs,
match_results< _Bi_iter, _Alloc > &__rhs) noexcept
Swaps two match results.
