Macro __cplusplusMacro __cplusplusMacro __cplusplus

    #ifndef __cplusplus
      #error C++ is required
    #elif __cplusplus > 199711L
      // C++11 (or newer) code goes here
    #else
      // old-school code goes here
    #endif
    C++98 #define __cplusplus199711L
    C++03 #define __cplusplus199711L
    C++11 #define __cplusplus201103L
    C++14 #define __cplusplus201402L
    C++17 #define __cplusplus201703L
    C++20 #define __cplusplus202002L

    If a compiler was released between C++ standards, values for __cplusplus might differ from the ones in the above table. However, you can always rely on the fact that the value of __cplusplus for a newer standard will be strictly larger than that of the previous standard.