How do I check for C++20 support? What is the value of __cplusplus for C++20?

  • A+

Related to questions How do I check for C++11 support? and What is the value of __cplusplus for C++17?

How can I inquire whether the compiler can handle / is set up to use C++20? I know that it is in principle possible to inquire the C++ version by:

#if __cplusplus > ???   // C++20 code here #endif 

What should ??? be for C++20?


It's too early for that.

Until the standard replaces it, use:

#if __cplusplus > 201703L   // C++20 code #endif 

since the predefined macro of C++20 is going to be larger than the one of C++17.

cpp.predefined specifies (emphasis mine):


The integer literal 201703L. [Note: It is intended that future versions of this International Standard will replace the value of this macro with a greater value.]

In Nov 2018, the macros used are:


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: