c++ - How to know if libstdc++ support std::regex -


i have application uses std::regex,it builds , runs fine on computer. however, on ubuntu 14.04, builds doesn't work, because std::regex not implemented on old libstdc++.

i #ifdef lines in code workaround issue can seem find reliable way figure out if libstdc++ supports or not.

i'm using cmake, happy if able version of library (/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19 -> 6019).

you can write simple test check whether works. first 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 have include variable have_cxx_11_regex config.h. can test #ifdef have_cxx_11_regex.


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -