Is there any native library in STL which is tested and works without any extra compiler options?
I tried to use
, but the compiler outputs this:
G++ 4.3 (and presumably later versions as well) is just being careful about the header files for maximum standards conformance.
If you're programming in C++98 (the current standard that's been around for a while), then regular expression support was added in tech report 1, and the and the header files are in a special tr1
directory, and the contents are in a special namespace std::tr1
.
In the new C++0x standard, the regular expression support has been merged into the standard library, so it can be found in the header regex
and namespace std
.
G++ makes sure that you use the right version for the --std=
version you specified on the command line, even though internally they're both the same implementation.
So to make regex work without switching to --std=c++0x
, just
#include <tr1/regex>
I'm pretty sure that regular expression support was added in C++0x, so there are no STL things that support it until then. If you don't want to use c++0x, you could use Boost instead, but that's not in the STL.
You could try using Boost.Regex instead of the c++0x headers.
Also the STL is not the same thing as the standard library. It used to stand for "Standard Template Library" back when that was an offering of SGI. The standard library did not adopt everything int the STL (rope and slist) and covers much more ground than the STL did (iostreams, all the tr1, tr2, and c++0x headers).