std::regex_token_iterator<BidirIt,CharT,Traits>::regex_token_iterator
来自cppreference.com
<tbody>
</tbody>
regex_token_iterator(); |
(1) | (C++11 起) |
regex_token_iterator( BidirIt a, BidirIt b, const regex_type& re, int submatch = 0, std::regex_constants::match_flag_type m = std::regex_constants::match_default ); |
(2) | (C++11 起) |
regex_token_iterator( BidirIt a, BidirIt b, const regex_type& re, const std::vector<int>& submatches, std::regex_constants::match_flag_type m = std::regex_constants::match_default ); |
(3) | (C++11 起) |
regex_token_iterator( BidirIt a, BidirIt b, const regex_type& re, std::initializer_list<int> submatches, std::regex_constants::match_flag_type m = std::regex_constants::match_default ); |
(4) | (C++11 起) |
template< std::size_t N > regex_token_iterator( BidirIt a, BidirIt b, const regex_type& re, const int (&submatches)[N], std::regex_constants::match_flag_type m = std::regex_constants::match_default ); |
(5) | (C++11 起) |
regex_token_iterator( const regex_token_iterator& other ); |
(6) | (C++11 起) |
regex_token_iterator( BidirIt a, BidirIt b, const regex_type&& re, int submatch = 0, std::regex_constants::match_flag_type m = std::regex_constants::match_default ) = delete; |
(7) | (C++11 起) |
regex_token_iterator( BidirIt a, BidirIt b, const regex_type&& re, const std::vector<int>& submatches, std::regex_constants::match_flag_type m = std::regex_constants::match_default ) = delete; |
(8) | (C++11 起) |
regex_token_iterator( BidirIt a, BidirIt b, const regex_type&& re, std::initializer_list<int> submatches, std::regex_constants::match_flag_type m = std::regex_constants::match_default ) = delete; |
(9) | (C++11 起) |
template< std::size_t N > regex_token_iterator( BidirIt a, BidirIt b, const regex_type&& re, const int (&submatches)[N], std::regex_constants::match_flag_type m = std::regex_constants::match_default ) = delete; |
(10) | (C++11 起) |
构造新的 regex_token_iterator:
1) 默认构造函数。构造序列尾迭代器。
2-5) 首先,将
submatches 或 submatch 实参的请求的子匹配列表,复制到存储于迭代器的成员列表中,再通过传递 a、b、re 和 m 到其四参数构造函数(该构造函数进行对 std::regex_search 的初始调用)构造成员 std::regex_iterator,然后设置 submatches 的内部计数器为零。
- 若构造后,成员
regex_iterator不是序列尾迭代器,则设置成员指针为当前 std::sub_match 的地址。 - 否则(若成员
regex_iterator是序列尾迭代器),但值-1是submatches/submatch中的值之一,则将*this转变为指向范围[a,b)的后缀迭代器(整个字符串是非匹配的后缀)。 - 否则,(若
-1不在子匹配列表中),将*this转变为序列尾迭代器。
若 submatches 中任何值小于 -1 则行为未定义。
6) 复制构造函数:进行逐元素复制(包含对成员
regex_iterator 和指向 sub_match 的成员指针的复制)。7-10) 禁止以临时 regex 调用重载 (2-5) ,因为否则返回的迭代器会被立即非法化。
参数
| a | - | 指向目标字符序列起始的老式双向迭代器 (LegacyBidirectionalIterator) |
| b | - | 指向目标字符序列末尾的老式双向迭代器 (LegacyBidirectionalIterator) |
| re | - | 用于在目标字符序列中搜索的正则表达式 |
| submatch | - | 应当返回的子匹配的索引。"0" 表示整体匹配,而 "-1" 表示未匹配的部分(例如匹配间的部分) |
| submatches | - | 应当在每个匹配内迭代的子匹配的索引的序列,可能包含代表非匹配片段的特殊值 -1
|
| m | - | 掌管 re 行为的标志
|
参阅
| 本节未完成 原因:暂无示例 |
缺陷报告
下列更改行为的缺陷报告追溯地应用于以前出版的 C++ 标准。
| 缺陷报告 | 应用于 | 出版时的行为 | 正确行为 |
|---|---|---|---|
| LWG 2332 | C++11 | 从临时 basic_regex 构造的 regex_token_iterator 立即变为非法
|
通过被删除的重载禁止这种构造 |