Why doesn't this work:
#include <regex>
int main() {
return 0;
}
Compiled as:
clang++ -std=c++11 -stdlib=libstdc++ temp.cpp
temp.cpp:1:10: fatal error: 'regex' file not found
#include <regex>
^
1 error generated.
clang++ --version
Apple LLVM version 7.0.0 (clang-700.1.76)
Target: x86_64-apple-darwin14.5.0
Thread model: posix
If I allow stdlib
to be libc++
then it compiles. Regex is c++11
, but clang
doesn't seem to have a problem with both -std=c++11 -stdlib=libstdc++
per se. On my machine at least, it looks like there's something I could use in /usr/include/regex.h
, but that's not standard, and besides there are things other than regex I'd like to use (e.g. std::to_string).
The reason this has come up is because I'd like to link to a 3rd party library (for which I don't have the source) which is complied as std::string
and not std::__1::basic_string
, but my code uses std::regex
and std::to_string
. I'm not sure I want to introduce a dependency on boost.
<regex>
was not properly functional in libstdc++ until the version that shipped with gcc-4.9, see this. Maybe you have an older version. – Exurbialibc++
. – Unpleasantness