Difference between revisions of "cpp/regex/match results"
m (Shorten template names. Use {{lc}} where appropriate.) |
m (Update links.) |
||
Line 49: | Line 49: | ||
===Member functions=== | ===Member functions=== | ||
{{dsc begin}} | {{dsc begin}} | ||
− | {{dsc inc | cpp/regex/match_results/ | + | {{dsc inc | cpp/regex/match_results/constructor}} |
− | {{dsc inc | cpp/regex/match_results/ | + | {{dsc inc | cpp/regex/match_results/destructor}} |
− | {{dsc inc | cpp/regex/match_results/ | + | {{dsc inc | cpp/regex/match_results/operator{{=}}}} |
− | {{dsc inc | cpp/regex/match_results/ | + | {{dsc inc | cpp/regex/match_results/get_allocator}} |
{{dsc h2 | State}} | {{dsc h2 | State}} | ||
Line 58: | Line 58: | ||
{{dsc h2 | Size}} | {{dsc h2 | Size}} | ||
− | {{dsc inc | cpp/regex/match_results/ | + | {{dsc inc | cpp/regex/match_results/empty}} |
− | {{dsc inc | cpp/regex/match_results/ | + | {{dsc inc | cpp/regex/match_results/size}} |
− | {{dsc inc | cpp/regex/match_results/ | + | {{dsc inc | cpp/regex/match_results/max_size}} |
{{dsc h2 | Element access}} | {{dsc h2 | Element access}} | ||
− | {{dsc inc | cpp/regex/match_results/ | + | {{dsc inc | cpp/regex/match_results/length}} |
− | {{dsc inc | cpp/regex/match_results/ | + | {{dsc inc | cpp/regex/match_results/position}} |
− | {{dsc inc | cpp/regex/match_results/ | + | {{dsc inc | cpp/regex/match_results/str}} |
− | {{dsc inc | cpp/regex/match_results/ | + | {{dsc inc | cpp/regex/match_results/operator_at}} |
− | {{dsc inc | cpp/regex/match_results/ | + | {{dsc inc | cpp/regex/match_results/prefix}} |
− | {{dsc inc | cpp/regex/match_results/ | + | {{dsc inc | cpp/regex/match_results/suffix}} |
{{dsc h2 | Iterators}} | {{dsc h2 | Iterators}} | ||
− | {{dsc inc | cpp/regex/match_results/ | + | {{dsc inc | cpp/regex/match_results/begin}} |
− | {{dsc inc | cpp/regex/match_results/ | + | {{dsc inc | cpp/regex/match_results/end}} |
{{dsc h2 | Format}} | {{dsc h2 | Format}} | ||
− | {{dsc inc | cpp/regex/match_results/ | + | {{dsc inc | cpp/regex/match_results/format}} |
{{dsc h2 | Modifiers}} | {{dsc h2 | Modifiers}} | ||
− | {{dsc inc | cpp/regex/match_results/ | + | {{dsc inc | cpp/regex/match_results/swap}} |
{{dsc end}} | {{dsc end}} | ||
Line 84: | Line 84: | ||
===Non-member functions=== | ===Non-member functions=== | ||
{{dsc begin}} | {{dsc begin}} | ||
− | {{dsc inc | cpp/regex/match_results/ | + | {{dsc inc | cpp/regex/match_results/operator_cmp}} |
− | {{dsc inc | cpp/regex/match_results/ | + | {{dsc inc | cpp/regex/match_results/swap2}} |
{{dsc end}} | {{dsc end}} | ||
Revision as of 23:22, 31 May 2013
Defined in header <regex>
|
||
template< class BidirIt, |
(since C++11) | |
The class template std::match_results holds a collection of character sequences that represent the result of a regular expression match.
This is a specialized allocator-aware container. It can only be default created, obtained from std::regex_iterator, or modified by std::regex_search or std::regex_match. Because std::match_results
holds std::sub_matches, each of which is a pair of iterators into the original character sequence that was matched, it's undefined behavior to examine std::match_results
if the original character sequence was destroyed or iterators to it were invalidated for other reasons.
The first sub_match (index 0) contained in a match_result always represents the full match within a target sequence made by a regex, and subsequent sub_matches represent sub-expression matches corresponding in sequence to the left parenthesis delimiting the sub-expression in the regex.
Contents |
Type requirements
Specializations
Several specializations for common character sequence types are provided:
Defined in header
<regex> | |
Type | Definition |
cmatch
|
match_results<const char*> |
wcmatch
|
match_results<const wchar_t*> |
smatch
|
match_results<std::string::const_iterator> |
wsmatch
|
match_results<std::wstring::const_iterator> |
Member types
Member type | Definition |
allocator_type
|
Allocator |
value_type
|
std::sub_match<BidirIt> |
const_reference
|
const value_type& |
reference
|
const_reference |
const_iterator
|
implementation defined (depends on the underlying container) |
iterator
|
const_iterator |
difference_type
|
std::iterator_traits<BidirIt>::difference_type |
size_type
|
std::allocator_traits<Alloc>::size_type |
char_type
|
std::iterator_traits<BidirIt>::value_type |
string_type
|
std::basic_string<char_type> |
Member functions
constructs the object (public member function) | |
destructs the object (public member function) | |
assigns the contents (public member function) | |
returns the associated allocator (public member function) | |
State | |
(public member function) | |
Size | |
checks whether the match was successful (public member function) | |
returns the number of matches in a fully-established result state (public member function) | |
returns the maximum possible number of sub-matches (public member function) | |
Element access | |
returns the length of the particular sub-match (public member function) | |
returns the position of the first character of the particular sub-match (public member function) | |
returns the sequence of characters for the particular sub-match (public member function) | |
returns specified sub-match (public member function) | |
returns sub-sequence between the beginning of the target sequence and the beginning of the full match (public member function) | |
returns sub-sequence between the end of the full match and the end of the target sequence (public member function) | |
Iterators | |
returns iterator to the beginning of the list of sub-matches (public member function) | |
returns iterator to the end of the list of sub-matches (public member function) | |
Format | |
formats match results for output (public member function) | |
Modifiers | |
swaps the contents (public member function) |
Non-member functions
(removed in C++20) |
lexicographically compares the values in the two match result (function template) |
specializes the std::swap algorithm (function template) |