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?

3
  • Are you compiling with -std=c++0x ? Commented Jan 17, 2011 at 19:15
  • Yes. Seems the issue is regex only being partly implemented as yet. Commented Jan 17, 2011 at 19:59
  • 1
    you may use <boost/regex> instead. Commented Oct 30, 2012 at 14:38

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Here's a link to the c++0x project that covers all versions of gcc and their support statuses. gcc.gnu.org/projects/cxx0x.html
0

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

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.