std::regex_...ken_iterator(3)
πΈ NAME πΈ
std::regex_token_iterator::regex_token_iterator β literally the constructor for std::regex_token_iterator, with the exact same name as the class. We're in the C++ Standard Library manual, page std::regex_...ken_iterator(3), and yes bestie, C++ really said "constructor name = class name, periodt." π
β¨ SYNOPSIS β¨
regex_token_iterator(); (1)
(since C++11)
regex_token_iterator( BidirIt a, BidirIt b,
const regex_type& re,
int submatch = 0, (2)
(since C++11)
std::regex_constants::match_flag_type m =
std::regex_constants::match_default );
regex_token_iterator( BidirIt a, BidirIt b,
const regex_type& re,
const std::vector<int>& submatches, (3)
(since C++11)
std::regex_constants::match_flag_type m =
std::regex_constants::match_default );
regex_token_iterator( BidirIt a, BidirIt b,
const regex_type& re,
std::initializer_list<int> submatches, (4)
(since C++11)
std::regex_constants::match_flag_type m =
std::regex_constants::match_default );
template< std::size_t N >
regex_token_iterator( BidirIt a, BidirIt b,
const regex_type& re, (5)
(since C++11)
const int (&submatches)[N],
std::regex_constants::match_flag_type m =
std::regex_constants::match_default );
regex_token_iterator( const regex_token_iterator& other ); (6)
(since C++11)
regex_token_iterator( BidirIt a, BidirIt b,
const regex_type&& re,
int submatch = 0, (7)
(since C++11)
std::regex_constants::match_flag_type m =
std::regex_constants::match_default ) =
delete;
regex_token_iterator( BidirIt a, BidirIt b,
const regex_type&& re,
const std::vector<int>& submatches, (8)
(since C++11)
std::regex_constants::match_flag_type m =
std::regex_constants::match_default ) =
delete;
regex_token_iterator( BidirIt a, BidirIt b,
const regex_type&& re,
std::initializer_list<int> submatches, (9)
(since C++11)
std::regex_constants::match_flag_type m =
std::regex_constants::match_default ) =
delete;
template< std::size_t N >
regex_token_iterator( BidirIt a, BidirIt b,
const regex_type&& re,
const int (&submatches)[N],
(10) (since C++11)
std::regex_constants::match_flag_type m =
std::regex_constants::match_default ) =
delete;
Okay so this constructs a new regex_token_iterator, and the numbered tea is exactly this:
- 1) Default constructor. Constructs the end-of-sequence iterator.
- 2β5) First, copies the list of the requested submatch out of the
submatchesorsubmatchargument into the member list stored in the iterator and constructs the memberstd::regex_iteratorby passinga,b,re, andmto its four-argument constructor (that constructor performs the initial call tostd::regex_search) and sets the internal counter of submatches to zero.- If, after construction, the member
regex_iteratoris not an end-of-sequence iterator, sets the member pointer to the address of the currentstd::sub_match. - Otherwise (if the member
regex_iteratoris an end-of-sequence iterator), but the value-1is one of the values insubmatches/submatch, turns*thisinto a suffix iterator pointing at the range[a, b)(the entire string is the non-matched suffix). - Otherwise (if
-1is not in the list ofsubmatches), turns*thisinto the end-of-sequence iterator.
- If, after construction, the member
β οΈ The behavior is undefined if any value insubmatchesis less than-1. Not a vibe, bestie β do not go there.
- 6) Copy constructor: performs member-wise copy (including making a copy of the member
regex_iteratorand the member pointer to currentsub_match). - 7β10) The overloads
(2-5)are prohibited from being called with a temporary regex since otherwise the returned iterator would be immediately invalidated.
π PARAMETERS π
aβLegacyBidirectionalIteratorto the beginning of the target character sequencebβLegacyBidirectionalIteratorto the end of the target character sequencereβ regular expression used to search the target character sequencesubmatchβ the index of the submatch that should be returned."0"represents the entire match, and"-1"represents the parts that are not matched (e.g, the stuff between matches)submatchesβ the sequence of submatch indices that should be iterated over within each match, may include the special value-1for the non-matched fragmentsmβ flags that govern the behavior ofre
π EXAMPLE π
This section is incomplete
Reason: no example
π₯ DEFECT REPORTS π₯
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
- DR:
LWG 2332 - Applied to:
C++11 - Behavior as published: a
regex_token_iteratorconstructed from a temporarybasic_regexbecame invalid immediately - Correct behavior: construction is disallowed via deleted overloads
π CATEGORY π
Todo no example
okay that's the whole page, bestie π«Ά β source http://cppreference.com, version/date 2024.06.10, page std::regex_...ken_iterator(3). mwah π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms