如standard中所指定: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声明的内容匹配。
关于c++ - 在Clang中regex_constants的实现错误?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/56505648/