Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Options for using C++11 <regex> with a circa 2013 compiler

Tags:

regex

c++11

Is there any full/correct implementation available (right now) for C++11 regex?

Note on Compiler support vs. Library support:

Compiler Support = compiler recognizes any new syntax added to the language for the feature in question. Code utilizing the new feature added to your program will compile.

Library Support = library updated to actually implement the feature. Code added to your program and linked to the library will work.

*Edit: I've updated this summary with new information and moved it into an answer below.

like image 755
Arbalest Avatar asked Sep 03 '13 04:09

Arbalest


3 Answers

Per stack exchange policy about it being ok to answer your own question I am updating the summary part of the question with new info and moving it into this answer.

GCC: Does not provide a working regex until GCC 4.9.0

Clang: Compiles regex

Standard Library:

  • regex only supported by libstdc++ since GCC 4.9.0 (GNU's standard lib)
  • regex is supported by libc++ (LLVM's standard lib)
  • libc++ fully verified on Mac OS
  • libc++ can be built from source for other platforms.
  • (I built and verified some of regex on Linux)

MSVC: Regex works since MSVC 2010 (Per answer from @Laurent and associated up votes)

Boost: C++11 regex is "based on" or "modeled after" Boost. I take that to mean not exactly the same. If there is a definitive list of differences please comment with a link.

like image 119
Arbalest Avatar answered Nov 15 '22 19:11

Arbalest


I've used the <regex> module since MSVC 2010 and it worked perfectly for my need (using the doc from cplusplus.com).

So if you intend to develop on a Windows environment, I would recommend opting for MSVC 2010 or 2012. It works out of the box !

like image 28
Laurent Jalbert Simard Avatar answered Nov 15 '22 20:11

Laurent Jalbert Simard


Clang is C++11 feature complete. You can check which feature is available in which version here: Clang C++11 features

like image 1
RedX Avatar answered Nov 15 '22 20:11

RedX