构造函数
regex
因为临时对象被删除,因为
迭代器不复制
正则表达式
但是保持对这个对象的引用。
防止将临时变量传递到迭代器中
.
根据
reference
:
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;
因此,您需要做的是将regex创建为
L值
std::string str("abc");
std::string regex("b");
std::regex r(regex);
std::regex_token_iterator<std::string::const_iterator> a(
str.begin(), str.end(), r, -1);
const regex_type& re
-所以可以将regex的临时对象传递给迭代器的ctor,但它会导致
.