Is there a way to detect at compile-time if the compiler supports certain features of C++11? For example, something like this:
#ifndef VARIADIC_TEMPLATES_SUPPORTED #error "Your compiler doesn't support variadic templates. :(" #else template <typename... DatatypeList> class Tuple { // ... } #endif
Status of Experimental C++11 Support in GCC 4.8 GCC provides experimental support for the 2011 ISO C++ standard. This support can be enabled with the -std=c++11 or -std=gnu++11 compiler options; the former disables GNU extensions.
Support for C11 and C17 standards is available in Visual Studio 2019 version 16.8 and later.
Type “gcc –version” in command prompt to check whether C compiler is installed in your machine.
There is a constant named __cplusplus
that C++ compilers should set to the version of the C++ standard supported see this
#if __cplusplus <= 199711L #error This library needs at least a C++11 compliant compiler #endif
It is set to 199711L in Visual Studio 2010 SP1, but I do not know if vendors will be so bold to increase it already if they just have (partial) compiler-level support versus a standard C++ library with all the C++11 changes.
So Boost's defines mentioned in another answer remain the only sane way to figure out if there is, for example, support for C++11 threads and other specific parts of the standard.
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