wiki:hpp-version
<version>
<version> provides __cpp_* feature-test macros (C++20) that tell you which C++ features are available in your compiler and standard library. For example, __cpp_concepts is defined if C++20 concepts are supported.
Use these in preprocessor conditionals to enable features selectively.
Example
This example uses feature-test macros to conditionally report whether C++20 concepts and ranges are supported by the compiler.
// compile: g++ -std=c++20 -o versionexample versionexample.cpp // run: ./versionexample // description: check for C++ features #include <version> #include <iostream> int main() { #ifdef __cpp_concepts std::cout << "concepts supported\n"; #endif #ifdef __cpp_ranges std::cout << "ranges supported\n"; #endif return 0; }
wiki/hpp-version.md · Last modified: by 127.0.0.1
