I have an application which uses std::regex,it builds and runs fine on my computer. However, on ubuntu 14.04, it builds but doesn't work, because std::regex is not implemented on that old libstdc++.
I would like to #ifdef some lines in my code to workaround this issue but can seem to find a reliable way to figure out if the libstdc++ supports it or not.
I'm using cmake, so I would also be happy if I was able to get the version of the library (/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19 -> 6019).
You can write a simple test to check whether it works. First the CMake part:
include(CMakePushCheckState)
include(CheckCXXSourceRuns)
cmake_push_check_state()
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++11")
check_cxx_source_runs("
#include <regex>
int main() {
return std::regex_match(\"StackOverflow\", std::regex(\"(stack)(.*)\"));
}
" HAVE_CXX_11_REGEX)
cmake_pop_check_state()
Then you have to include the variable HAVE_CXX_11_REGEX into you config.h. Then you can test this with #ifdef HAVE_CXX_11_REGEX.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With