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 特化將不會被呼叫。
如果迭代器是序列末尾迭代器,則行為未定義。
[編輯] 引數
(無)