std::regex_iterator<BidirIt,CharT,Traits>:: regex_iterator
|
regex_iterator
(
)
;
|
(1) | (C++11以降) |
|
regex_iterator
(
BidirIt a, BidirIt b,
const
regex_type
&
re,
|
(2) | (C++11以降) |
|
regex_iterator
(
const
regex_iterator
&
)
;
|
(3) | (C++11以降) |
|
regex_iterator
(
BidirIt, BidirIt,
const
regex_type
&&
,
|
(4) | (C++11以降) |
新しい
regex_iterator
を構築します:
[
a
,
b
)
から、正規表現
re
およびマッチング動作を制御するフラグ
m
を用いて
regex_iterator
を構築します。このコンストラクタは、このデータを使用して
std::regex_search
への初期呼び出しを実行します。この初期呼び出しの結果が
false
の場合、
*
this
は終端イテレータに設定されます。
regex_iterator
をコピーします。
パラメータ
| a | - | LegacyBidirectionalIterator 対象文字シーケンスの先頭を指す |
| b | - | LegacyBidirectionalIterator 対象文字シーケンスの終端を指す |
| re | - | 対象文字シーケンスの検索に使用する正規表現 |
| m | - | re の動作を制御するフラグ |
例
#include <iostream> #include <regex> #include <string_view> int main() { constexpr std::string_view str{R"( #ONE: *p = &Mass; #Two: MOV %rd, 42 )"}; const std::regex re("[a-w]"); // regex_iteratorを作成、オーバーロード(2) auto it = std::regex_iterator<std::string_view::iterator> { str.cbegin(), str.cend(), re // reは左辺値。即時式が使用された場合(例:std::regex{"[a-z]"})、 // これはエラーを生成する。オーバーロード(4)が削除されているため }; for (decltype(it) last /* オーバーロード (1) */; it != last; ++it) std::cout << (*it).str(); std::cout << '\n'; }
出力:
password
不具合報告
以下の動作変更の欠陥報告書は、以前に公開されたC++規格に対して遡及的に適用されました。
| DR | 適用対象 | 公開時の動作 | 正しい動作 |
|---|---|---|---|
| LWG 2332 | C++11 |
一時オブジェクトの
basic_regex
から構築された
regex_iterator
は
直ちに無効化されていた |
削除されたオーバーロードにより、そのような構築は許可されない |