regex_constants 在 clang 中的错误实现?
Wrong implementation for regex_constants in clang?
如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 的规定。
match_prev_avail:
--first is a valid iterator position. When this flag is set the flags match_not_bol and match_not_bow shall be ignored by the regular expression
algorithms (30.11) and iterators (30.12)
如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 的规定。
match_prev_avail: --first is a valid iterator position. When this flag is set the flags match_not_bol and match_not_bow shall be ignored by the regular expression algorithms (30.11) and iterators (30.12)