使用C++ 11 regexp和gcc 4.8.2时的结果很奇怪(但与Boost regexp配合使用)

Phi*_*ßen 8 c++ regex gcc c++11 gcc4.8

我尝试使用C++ 11的正则表达式,但即使在简单的例子中也失败了.从外面看,似乎只比较字符串,例如:

std::regex_match(std::string{""}, std::regex{"a?"})   // false (???)
std::regex_match(std::string{"a?"}, std::regex{"a?"}) // true  (???)
Run Code Online (Sandbox Code Playgroud)

相比之下,Boost的regexp库的行为与我预期的一样:

boost::regex_match(std::string{""}, boost::regex{"a?"})   // true  (OK)
boost::regex_match(std::string{"a?"}, boost::regex{"a?"}) // false (OK)
Run Code Online (Sandbox Code Playgroud)

我使用GCC 4.8.2和clang 3.4(也使用GCC的STL库)进行了测试.库已损坏,或者我不理解C++ 11标准定义的语法.

Joe*_*e Z 7

它在GCC 4.8.x中不受支持.查看相应的Bugzilla条目:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53631

具体来说:"现在正在实施正则表达式.应该加入GCC 4.9 :)"