在https://en.cppreference.com/w/cpp/regex/regex_traits/transform_primary中提出了以下示例片段:
#include <iostream>
#include <regex>
int main()
{
std::locale::global(std::locale("en_US.UTF-8"));
std::wstring str = L"AÀÁÂÃÄÅaàáâãäå";
std::wregex re(L"[[=a=]]*", std::regex::basic);
std::cout << std::boolalpha << std::regex_match(str, re) << '\n';
}
也有人说应该输出true。但是,在 Debian 上使用 GCC 8 和 Clang 7 以及 macOS High Sierra 附带的 Clang 总是给出false尝试(您可以使用 cppreference 页面中的“运行”按钮直接测试它)。
有人可能会说 cppreference 页面是错误的,这肯定是可能的,但是阅读文档在我看来这也是正确的输出:据我所知,true字符串中的所有字符都在.stra
所以问题是:谁是对的?编译器还是 cppreference?为什么?