Strange results when using C ++ 11 regexp with gcc 4.8.2 (but works with Boost regexp)

I tried to use C ++ 11 regex but failed even in trivial examples. From the outside, it seems that only strings are compared, for example:

std::regex_match(std::string{""}, std::regex{"a?"}) // false (???) std::regex_match(std::string{"a?"}, std::regex{"a?"}) // true (???) 

In contrast, the regexp Boost library behaves as I expected:

 boost::regex_match(std::string{""}, boost::regex{"a?"}) // true (OK) boost::regex_match(std::string{"a?"}, boost::regex{"a?"}) // false (OK) 

I tested GCC 4.8.2 and clang 3.4 (also using the GCC STL library). Either the library is broken, or I donโ€™t understand the syntax defined by the C ++ 11 standard.

+8
c ++ gcc regex c ++ 11
source share
1 answer

It is not supported in GCC 4.8.x. Check the corresponding Bugzilla entry:

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

In particular: "The regular expression is now implemented. Must have GCC 4.9 :)"

+7
source share

All Articles