std::regex_iterator<BidirIt,CharT,Traits>::operator++, operator++(int)
regex_iterator& operator++(); |
(C++11 起) | |
regex_iterator operator++( int ); |
(C++11 起) | |
令迭代器前进到下一个匹配。
本节不完整 理由:解释得更好 |
首先,用 match[0].second 的值构造一个类型为 BidirIt
的局部变量。
如果迭代器持有一个零长度匹配且 start == end,则 *this 被设为序列结尾迭代器并返回函数。
否则,若迭代器持有一个零长度匹配,则该运算符调用下列函数:
regex_search(start, end, match, *pregex,
flags | regex_constants::match_not_null |
regex_constants::match_continuous);
如果该调用返回 true,则函数返回。
否则,该运算符自增 start
并如同最近一次的匹配不是零长度匹配那样继续。
若最近一次匹配不是零长度匹配,则运算符将 flags
设为 flags | regex_constants::match_prev_avail 并调用下列函数:
regex_search(start, end, match, *pregex, flags);
若该调用返回 false,则迭代器将 *this 设为序列结尾迭代器,函数返回。
在所有对 regex_search 的调用返回 true 的情况中,match.prefix().first 将等于 match[0].second 的前一个值,且对于范围 [
0,
match.size())
中每个使得 match[i].matched 为 true 的下标 i,match[i].position() 将返回 distance(begin, match[i].first)。
这意味着 match[i].position() 给出的是从目标序列开始处的偏移,这通常与从传入 regex_search 调用的序列开始处的偏移不同。
实现如何进行这些调整是未指定的。这意味着编译器可以调用一个实现特定的搜索函数,在这种情况下,用户定义的 regex_search 特化将不会被调用。
如果迭代器是序列末尾迭代器,则行为未定义。
[编辑] 参数
(无)