std::regex_token_iterator::regex_token_iterator

regex_token_iterator();
(1) (C++11 起)
regex_token_iterator( BidirectionalIterator a, BidirectionalIterator 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( BidirectionalIterator a, BidirectionalIterator 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( BidirectionalIterator a, BidirectionalIterator 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( BidirectionalIterator a, BidirectionalIterator 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( BidirectionalIterator a, BidirectionalIterator b,

                      const regex_type&& re,
                      int submatch = 0,
                      std::regex_constants::match_flag_type m =

                          std::regex_constants::match_default ) = delete;
(7) (C++14 起)
regex_token_iterator( BidirectionalIterator a, BidirectionalIterator 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++14 起)
regex_token_iterator( BidirectionalIterator a, BidirectionalIterator 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++14 起)
template <std::size_t N>

regex_token_iterator( BidirectionalIterator a, BidirectionalIterator b,
                      const regex_type&& re,
                      const int (&submatches)[N],
                      std::regex_constants::match_flag_type m =

                          std::regex_constants::match_default ) = delete;
(10) (C++14 起)

构造新的 regex_token_iterator

1) 默认构造函数。构造序列尾迭代器。
2-5) 首先,复制出 submatchessubmatch 参数的请求的子匹配列表,到存储于迭代器的成员列表中,再通过传递 abrem 到其四参数构造函数(该构造函数进行到 std::regex_search 的初始调用)构造成员 std::regex_iterator ,然后设置子匹配的内部计数器为零。

submatches 中任何值小于 -1 则行为未定义。

6) 复制构造函数:进行逐元素赋值(包含复制成员 regex_iterator 和成员指向 sub_match 指针)。
7-10) 重载 2-5 禁止以临时 regex 调用,因为否则返回的迭代器会被立即非法化。

参数

a - 指向目标字符序列起始的双向迭代器 (BidirectionalIterator)
b - 指向目标字符序列结尾的双向迭代器 (BidirectionalIterator)
re - 用于在目标字符序列中搜索的正则表达式
submatch - 应当返回的子匹配下标。 "0" 表示完整匹配,而 "-1" 表示未匹配的部分(例如匹配间的填塞)。
submatches - 应当在每个匹配内迭代的子匹配下标的序列,对于非匹配碎片可能包含特殊值 -1
m - 掌管 re 行为的标志

参阅

版本历史

  • (当前 | 先前) 2017年10月13日 (五) 08:20Fruderica讨论 | 贡献. . (5,071字节) (+5,071). . (以“{{cpp/regex/regex_token_iterator/title | regex_token_iterator}} {{cpp/regex/regex_token_iterator/navbar}} {{dcl begin}} {{dcl | num=1 | since=c++11 | 1= regex_token...”为内容创建页面)