在叮当声中regex_constants实现错误

Wrong implementation for regex_constants in clang?

本文关键字:constants 实现 错误 regex 叮当声      更新时间:2023-10-16

如标准中指定:

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_availmatch_not_bol覆盖了.

似乎你在叮当声中发现了一个错误。(在这里提交:https://bugs.llvm.org/,因为它似乎还没有被报道(

我检查了 MSVC 1914,它给出了

0
0
0

与 GCC 4.9.2 相同(用于 cpp.sh 检查(

我重新检查了标准的.pdf形式(N4810(,这在 30.5.2 中与 cpp首选项所述相匹配。

match_prev_avail: --first 是一个有效的迭代器位置。设置此标志时,正则表达式应忽略match_not_bol和match_not_bow标志 算法 (30.11( 和迭代器 (30.12(