Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/regex/match results"

From cppreference.com
< cpp‎ | regex
m (+pmr typedefs)
m (fmt)
 
(8 intermediate revisions by 4 users not shown)
Line 3: Line 3:
 
{{dcl begin}}
 
{{dcl begin}}
 
{{dcl header|regex}}
 
{{dcl header|regex}}
{{dcl | num=1| since=c++11 | 1=
+
{{dcl|num=1|since=c++11|1=
 
template<
 
template<
 
     class BidirIt,
 
     class BidirIt,
Line 11: Line 11:
 
{{dcl|num=2|since=c++17|1=
 
{{dcl|num=2|since=c++17|1=
 
namespace pmr {
 
namespace pmr {
     template <class BidirectionalIterator>
+
     template <class >
     using match_results = std::match_results<BidirectionalIterator,
+
     using match_results = std::match_results<,
                               std::polymorphic_allocator<
+
                               std::polymorphic_allocator<
                                   std::sub_match<BidirectionalIterator>>>;
+
                                   std::sub_match<>>>;
 
}
 
}
 
}}
 
}}
 
{{dcl end}}
 
{{dcl end}}
  
The class template {{lc|std::match_results}} holds a collection of character sequences that represent the result of a regular expression match.
+
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 {{lc|std::regex_iterator}}, or modified by {{lc|std::regex_search}} or {{lc|std::regex_match}}. Because {{tt|std::match_results}} holds {{lc|std::sub_match}}es, each of which is a pair of iterators into the original character sequence that was matched, it's undefined behavior to examine {{tt|std::match_results}} if the original character sequence was destroyed or iterators to it were invalidated for other reasons.
+
This is a specialized allocator-aware container. It can only be default created, obtained from {{lc|std::regex_iterator}}, or modified by {{lc|std::regex_search}} or {{lc|std::regex_match}}. Because {{tt|std::match_results}} holds {{lc|std::sub_match}}es, each of which is a pair of iterators into the original character sequence that was matched, it's undefined behavior to examine {{tt|std::match_results}} if the original character sequence was destroyed or iterators to it were invalidated for other reasons.
  
The first {{tt|sub_match}} (index 0) contained in a {{tt|match_result}} always represents the full match within a target sequence made by a regex, and subsequent {{tt|sub_match}}es represent sub-expression matches corresponding in sequence to the left parenthesis delimiting the sub-expression in the regex.
+
The first {{|sub_match}} (index 0) contained in a {{tt|match_result}} always represents the full match within a target sequence made by a regex, and subsequent {{|sub_match}}es represent sub-expression matches corresponding in sequence to the left parenthesis delimiting the sub-expression in the regex.
  
{{tt|std::match_results}} meets the requirements of a constant {{concept|AllocatorAwareContainer}} and of a constant {{concept|SequenceContainer}}.
+
{{tt|std::match_results}} meets the requirements of a {{|AllocatorAwareContainer}} and of a {{|SequenceContainer}}.
  
 
===Type requirements===
 
===Type requirements===
 
{{par begin}}
 
{{par begin}}
{{par req concept | BidirIt | BidirectionalIterator}}
+
{{par req |BidirIt|BidirectionalIterator}}
{{par req concept | Alloc | Allocator}}
+
{{par req |Alloc|Allocator}}
 
{{par end}}
 
{{par end}}
  
Line 37: Line 37:
  
 
{{dsc begin}}
 
{{dsc begin}}
{{dsc header | regex}}
+
{{dsc header|regex}}
{{dsc hitem | Type | Definition}}
+
{{dsc hitem|Type|Definition}}
{{dsc | {{tt|std::cmatch}} | {{c|std::match_results<const char*>}}}}
+
{{dsc|{{tt|std::cmatch}}|{{c|std::match_results<const char*>}}}}
{{dsc | {{tt|std::wcmatch}} | {{c|std::match_results<const wchar_t*>}}}}
+
{{dsc|{{tt|std::wcmatch}}|{{c|std::match_results<const wchar_t*>}}}}
{{dsc | {{tt|std::smatch}} | {{c|std::match_results<std::string::const_iterator>}}}}
+
{{dsc|{{tt|std::smatch}}|{{c|std::match_results<std::string::const_iterator>}}}}
{{dsc | {{tt|std::wsmatch}} | {{c|std::match_results<std::wstring::const_iterator>}}}}
+
{{dsc|{{tt|std::wsmatch}}|{{c|std::match_results<std::wstring::const_iterator>}}}}
{{dsc | {{tt|std::pmr::cmatch}} {{mark c++17}} | {{c|std::pmr::match_results<const char*>}}}}
+
{{dsc|{{tt|std::pmr::cmatch}} {{mark c++17}}|{{c|std::pmr::match_results<const char*>}}}}
{{dsc | {{tt|std::pmr::wcmatch}} {{mark c++17}}| {{c|std::pmr::match_results<const wchar_t*>}}}}
+
{{dsc|{{tt|std::pmr::wcmatch}} {{mark c++17}}|{{c|std::pmr::match_results<const wchar_t*>}}}}
{{dsc | {{tt|std::pmr::smatch}} {{mark c++17}}| {{c|std::pmr::match_results<std::string::const_iterator>}}}}
+
{{dsc|{{tt|std::pmr::smatch}} {{mark c++17}}|{{c|std::pmr::match_results<std::string::const_iterator>}}}}
{{dsc | {{tt|std::pmr::wsmatch}} {{mark c++17}}| {{c|std::pmr::match_results<std::wstring::const_iterator>}}}}
+
{{dsc|{{tt|std::pmr::wsmatch}} {{mark c++17}}|{{c|std::pmr::match_results<std::wstring::const_iterator>}}}}
 
{{dsc end}}
 
{{dsc end}}
  
 
===Member types===
 
===Member types===
 
{{dsc begin}}
 
{{dsc begin}}
{{dsc hitem | Member type | Definition}}
+
{{dsc hitem|Member type|Definition}}
{{dsc | {{tt|allocator_type}} | {{c|Allocator}}}}
+
{{dsc|{{tt|allocator_type}}|{{|Allocator}}}}
{{dsc | {{tt|value_type}} | {{c|std::sub_match<BidirIt>}}}}
+
{{dsc|{{tt|value_type}}|{{c|std::sub_match<BidirIt>}}}}
{{dsc | {{tt|const_reference}} | {{c|const value_type&}}}}
+
{{dsc|{{tt|const_reference}}|{{c|const value_type&}}}}
{{dsc | {{tt|reference}} | {{c|value_type&}}}}
+
{{dsc|{{tt|reference}}|{{|value_type&}}}}
{{dsc | {{tt|const_iterator}} | ''implementation defined'' (depends on the underlying container)}}
+
{{dsc|{{tt|const_iterator}}|''implementationdefined'' (depends on the underlying container)}}
{{dsc | {{tt|iterator}} | {{c|const_iterator}}}}
+
{{dsc|{{tt|iterator}}|{{|const_iterator}}}}
{{dsc | {{tt|difference_type}} | {{c|std::iterator_traits<BidirIt>::difference_type}}}}
+
{{dsc|{{tt|difference_type}}|{{c|std::iterator_traits<BidirIt>::difference_type}}}}
{{dsc | {{tt|size_type}} | {{c|std::allocator_traits<Alloc>::size_type}}}}
+
{{dsc|{{tt|size_type}}|{{c|std::allocator_traits<Alloc>::size_type}}}}
{{dsc | {{tt|char_type}} | {{c|std::iterator_traits<BidirIt>::value_type}}}}
+
{{dsc|{{tt|char_type}}|{{c|std::iterator_traits<BidirIt>::value_type}}}}
{{dsc | {{tt|string_type}} | {{c|std::basic_string<char_type>}}}}
+
{{dsc|{{tt|string_type}}|{{c|std::basic_string<char_type>}}}}
 
{{dsc end}}
 
{{dsc end}}
  
 
===Member functions===
 
===Member functions===
 
{{dsc begin}}
 
{{dsc begin}}
{{dsc inc | cpp/regex/match_results/dsc constructor}}
+
{{dsc inc|cpp/regex/match_results/dsc constructor}}
{{dsc inc | cpp/regex/match_results/dsc destructor}}
+
{{dsc inc|cpp/regex/match_results/dsc destructor}}
{{dsc inc | cpp/regex/match_results/dsc operator{{=}}}}
+
{{dsc inc|cpp/regex/match_results/dsc operator{{=}}}}
{{dsc inc | cpp/regex/match_results/dsc get_allocator}}
+
{{dsc inc|cpp/regex/match_results/dsc get_allocator}}
  
{{dsc h2 | State}}
+
{{dsc h2|State}}
{{dsc mem fun | cpp/regex/match_results/ready | checks if the results are available}}
+
{{dsc mem fun|cpp/regex/match_results/ready|checks if the results are available}}
  
{{dsc h2 | Size}}
+
{{dsc h2|Size}}
{{dsc inc | cpp/regex/match_results/dsc empty}}
+
{{dsc inc|cpp/regex/match_results/dsc empty}}
{{dsc inc | cpp/regex/match_results/dsc size}}
+
{{dsc inc|cpp/regex/match_results/dsc size}}
{{dsc inc | cpp/regex/match_results/dsc max_size}}
+
{{dsc inc|cpp/regex/match_results/dsc max_size}}
  
{{dsc h2 | Element access}}
+
{{dsc h2|Element access}}
{{dsc inc | cpp/regex/match_results/dsc length}}
+
{{dsc inc|cpp/regex/match_results/dsc length}}
{{dsc inc | cpp/regex/match_results/dsc position}}
+
{{dsc inc|cpp/regex/match_results/dsc position}}
{{dsc inc | cpp/regex/match_results/dsc str}}
+
{{dsc inc|cpp/regex/match_results/dsc str}}
{{dsc inc | cpp/regex/match_results/dsc operator_at}}
+
{{dsc inc|cpp/regex/match_results/dsc operator_at}}
{{dsc inc | cpp/regex/match_results/dsc prefix}}
+
{{dsc inc|cpp/regex/match_results/dsc prefix}}
{{dsc inc | cpp/regex/match_results/dsc suffix}}
+
{{dsc inc|cpp/regex/match_results/dsc suffix}}
  
{{dsc h2 | Iterators}}
+
{{dsc h2|Iterators}}
{{dsc inc | cpp/regex/match_results/dsc begin}}
+
{{dsc inc|cpp/regex/match_results/dsc begin}}
{{dsc inc | cpp/regex/match_results/dsc end}}
+
{{dsc inc|cpp/regex/match_results/dsc end}}
  
{{dsc h2 | Format}}
+
{{dsc h2|Format}}
{{dsc inc | cpp/regex/match_results/dsc format}}
+
{{dsc inc|cpp/regex/match_results/dsc format}}
 
+
{{dsc h2 | Modifiers}}
+
{{dsc inc | cpp/regex/match_results/dsc swap}}
+
  
 +
 +
 
{{dsc end}}
 
{{dsc end}}
  
 
===Non-member functions===
 
===Non-member functions===
 
{{dsc begin}}
 
{{dsc begin}}
{{dsc inc | cpp/regex/match_results/dsc operator_cmp}}
+
{{dsc inc|cpp/regex/match_results/dsc operator_cmp}}
{{dsc inc | cpp/regex/match_results/dsc swap2}}
+
{{dsc inc|cpp/regex/match_results/dsc swap2}}
 
{{dsc end}}
 
{{dsc end}}
  
[[de:cpp/regex/match results]]
+
deesfritjakoptruzh
[[es:cpp/regex/match results]]
+
[[fr:cpp/regex/match results]]
+
[[it:cpp/regex/match results]]
+
[[ja:cpp/regex/match results]]
+
[[ko:cpp/regex/match results]]
+
[[pt:cpp/regex/match results]]
+
[[ru:cpp/regex/match results]]
+
[[zh:cpp/regex/match results]]
+

Latest revision as of 07:15, 25 December 2023