Namespaces
Variants

std::regex_token_iterator<BidirIt,CharT,Traits>:: regex_token_iterator

From cppreference.net
Regular expressions library
Classes
(C++11)
Algorithms
Iterators
Exceptions
Traits
Constants
(C++11)
Regex Grammar
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_iterator (该构造函数执行对 std::regex_search 的初始调用),并将 submatches 的内部计数器设为零。
  • 如果在构造后,成员 regex_iterator 不是序列末尾迭代器,则将成员指针设置为当前 std::sub_match 的地址。
  • 否则(如果成员 regex_iterator 是序列末尾迭代器),但值 - 1 submatches / submatch 中的值之一,则将 * this 转换为指向范围 [ a , b ) 后缀迭代器 (整个字符串是未匹配的后缀)。
  • 否则(如果 - 1 不在 submatches 列表中),则将 * this 转换为序列末尾迭代器。

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

6) 拷贝构造函数:执行成员逐一拷贝(包括拷贝成员 regex_iterator 以及指向当前 sub_match 的成员指针)。
7-10) 禁止使用临时正则表达式调用重载 (2-5) ,否则返回的迭代器将立即失效。

参数

td> 指向目标字符序列结束位置的 LegacyBidirectionalIterator
a - 指向目标字符序列起始位置的 LegacyBidirectionalIterator
b -
re - 用于搜索目标字符序列的正则表达式
submatch - 应返回的子匹配索引。"0"表示完整匹配,"-1"表示未匹配部分(例如匹配之间的内容)
submatches - 在每个匹配中应遍历的子匹配索引序列,可能包含特殊值 - 1 表示未匹配片段
m - 控制 re 行为的标志位

示例

缺陷报告

以下行为变更缺陷报告被追溯应用于先前发布的C++标准。

缺陷报告 应用于 发布时的行为 正确行为
LWG 2332 C++11 从临时 basic_regex 构造的
regex_token_iterator 会立即失效
通过删除重载禁止此类构造