Description of problem: It seems that starts_with(); method from std::string is missing on EL8.4 even when we use --std=c++2a with gcc (or clang). Both compilers supports C++20 but it seems the implementation is missing from libstdc++. [root@localhost ~]# g++ --std=c++2a starts_with.c starts_with.c: In function 'int main()': starts_with.c:6:19: error: 'std::__cxx11::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'starts_with' std::cout << var.starts_with("is") << std::endl; ^~~~~~~~~~~ Version-Release number of selected component (if applicable): gcc-c++-8.4.1-1.el8.x86_64 clang-devel-11.0.0-1.module+el8.4.0+8598+a071fcd5.x86_64 libstdc++-8.4.1-1.el8.x86_64 libgcc-8.4.1-1.el8.x86_64 clang-tools-extra-11.0.0-1.module+el8.4.0+8598+a071fcd5.x86_64 clang-11.0.0-1.module+el8.4.0+8598+a071fcd5.x86_64 gcc-8.4.1-1.el8.x86_64 clang-libs-11.0.0-1.module+el8.4.0+8598+a071fcd5.x86_64 libstdc++-devel-8.4.1-1.el8.x86_64 How reproducible: 100% Steps to Reproduce: 1. Create an example program with std::string and use the method starts_with(); 2. Fail to compile with bundled gcc and libstdc++ Actual results: Compiler error during compile phase. Expected results: Successful compilation. Additional info: std::string starts_with() is defined on C++20: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0457r2.html It should be supported if we have the option to enable --std=c++2a on compilers. Example code: #include <string> #include <iostream> int main() { std::string var = "this is a test"; std::cout << var.starts_with("is") << std::endl; return 0; }
C++20 support in GCC 8 is so early and experimental that I'm not minded to backport any new features there, sorry. starts_with was added in GCC 9. On RHEL 8 you can use the GCC Toolset to get a newer compiler than the system one: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/developing_c_and_cpp_applications_in_rhel_8/gcc-toolset-10_toolsets which has better C++20 support.
No problem Marek. I understood, incorrectly, that since gcc allowed --std=c++2a it would support it. I'll default back to --std=c++17. Thank you.
Further clarification: C++20 in GCC 10 is still experimental, even though the string::starts_with member is present.