Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/160.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 为什么此代码在VisualStudio中工作,但在gcc中失败?_C++_Regex - Fatal编程技术网

C++ 为什么此代码在VisualStudio中工作,但在gcc中失败?

C++ 为什么此代码在VisualStudio中工作,但在gcc中失败?,c++,regex,C++,Regex,此代码编译并运行(解析回溯符号) 在gcc中,调用regex\u match时,我得到“regex\u error”异常 而在VS2017中,它没有 const std::regex r( R"(\((\w*)\+\w*\)\s+\[(\w+)\])"); std::smatch m; const bool bMatch = std::regex_match(curStr,m,r); 有人能解释一下吗?我认为这是一个版本4.8.5 我甚至在5.3.0版之前发现了一些bug 因此,我建议您至少在

此代码编译并运行(解析回溯符号)

在gcc中,调用regex\u match时,我得到“regex\u error”异常 而在VS2017中,它没有

const std::regex r( R"(\((\w*)\+\w*\)\s+\[(\w+)\])");
std::smatch m;
const bool bMatch = std::regex_match(curStr,m,r);

有人能解释一下吗?

我认为这是一个版本
4.8.5

我甚至在
5.3.0版之前发现了一些bug
因此,我建议您至少在gcc中使用版本
5.4.0
upper


GCC(stdlibc++)并且从未真正工作得太好,您使用的是什么版本?@DeiDei,从未?它已经实施了一段时间了,我用词不当。我的意思是关于这件事有很多问题。这就是为什么我要求提供OP使用的版本。似乎英特尔编译器(icpc)也会出现这种情况。我最终用boost::regex而不是std::regex解决了这个问题