【发布时间】:2014-08-05 04:41:30
【问题描述】:
我正在关注 Stroustrup 的 C++ 之旅 - 第 7.3.1 节(第 79 页)中的一个示例。此代码在 VS 2013 Update 3 上编译,但在运行时失败:
regex pat {R"(\w{2}\s+(\d{5}))"};
smatch matches;
if (regex_search(string{"CA 90210"}, matches, pat))
{
if ((matches.size() > 1) && matches[1].matched)
{
cout << matches[1] << endl;
}
}
知道发生了什么吗?它在matches[1] 上失败,我试图将捕获组结果输出到标准输出。我看到的运行时断言是“字符串迭代器不兼容”。
【问题讨论】: