c++ - clang 中 regex_constants 的错误实现?
问题描述
如标准中规定:
match_prev_avail
: --first 是一个有效的迭代器位置。设置后,会导致 match_not_bol 和 match_not_bow 被忽略
但我运行以下代码并得到:
#include <regex>
#include <iostream>
using namespace std;
int main()
{
regex re0("^bcd");
string str = "abcd";
std::string::iterator start = str.begin() + 1;
cout << regex_search(start, str.end(), re0, regex_constants::match_not_bol) << endl;
cout << regex_search(start, str.end(), re0, regex_constants::match_prev_avail) << endl;
cout << regex_search(start, str.end(), re0, regex_constants::match_prev_avail | regex_constants::match_not_bol) << endl;
}
输出:
0
1
0
似乎match_prev_avail
被覆盖了match_not_bol
。
解决方案
似乎您在 clang 中发现了一个错误。(在这里归档:https ://bugs.llvm.org/ ,因为它似乎还没有被报告)
我检查了 MSVC 1914,它给出了
0
0
0
与 GCC 4.9.2 相同(使用 cpp.sh 检查)
我重新检查了标准 (N4810) 的 .pdf 格式,这在 30.5.2 中与cppreference状态相符。
match_prev_avail: --first 是一个有效的迭代器位置。当设置此标志时,正则表达式算法 (30.11) 和迭代器 (30.12) 将忽略标志 match_not_bol 和 match_not_bow
推荐阅读
- python - 如何查找不在 OneToOneField 右侧的项目?
- javascript - Cant get firebase to stop overriding old pictures when I upload them in javascript/jquery
- python - 访问python列表循环中的第二个值
- python - 如何以 ~C 速度排空/耗尽异步发电机?
- php - webpack encore symfony4 中的引导程序和 jquery
- uml - 我应该使用 UML 跟踪还是实现
- go - 在一片处理程序中注册一个 http URL 处理程序
- c# - 当 JavaScript 被缩小时,捆绑会产生冲突
- azure-data-explorer - 如何编写 Kusto 查询以在一张表中获取结果?
- angular - 角度应用程序上的多个根模块