C++0x regex in GCC
Asked Answered
R

2

11

The following code:

#include <regex>
using namespace std;

(snippage)

regex_search(s, m, re);

works in Microsoft C++, but GCC 4.4.3 gives the following error message:

/usr/include/c++/4.4/tr1_impl/regex:2255: warning: inline function ‘bool std::regex_search(_Bi_iter, _Bi_iter, std::match_results<_Bi_iter, _Allocator>&, const std::basic_regex<_Ch_type, _Rx_traits>&, std::regex_constants::match_flag_type) [with _Bi_iter = __gnu_cxx::__normal_iterator, std::allocator > >, _Allocator = std::allocator, std::allocator > > > >, _Ch_type = char, _Rx_traits = std::regex_traits]’ used but never defined

Of course it wouldn't surprise me if regex were simply one of the C++0x features still on the to-do list for GCC, but what I'm scratching my head over is, in that case, why does it happily take the include directive, variable declarations etc. and only trip over the function call (which it even seems to understand).

Is there something I'm missing?

Respective answered 17/1, 2011 at 18:48 Comment(3)
Are you compiling with -std=c++0x ?Selfexamination
Yes. Seems the issue is regex only being partly implemented as yet.Respective
you may use <boost/regex> instead.Heimer
D
15

The regex library was mostly not implemented in libstdc++ up to branch 4.8.

Versions 4.9 and above do have <regex> implemented though.

Damondamour answered 17/1, 2011 at 19:25 Comment(2)
Here's a link to the c++0x project that covers all versions of gcc and their support statuses. gcc.gnu.org/projects/cxx0x.htmlRoundly
<regex> is now implemented as of GCC 4.9Domeniga
J
0

For g++, compile with flag "-std=c++0x"

Jabalpur answered 30/3, 2012 at 15:57 Comment(1)
This will only work for versions of gcc that have the feature implemented. For example I was trying to use std::basic_regex but there is no implementation behind this function in gcc 4.4 and 4.5.Roundly

© 2022 - 2024 — McMap. All rights reserved.