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标准定义的语法.
它在GCC 4.8.x中不受支持.查看相应的Bugzilla条目:
具体来说:"现在正在实施正则表达式.应该加入GCC 4.9 :)"