How do I get the new C++20 standard?

I write in c++ in visual studio 2017, quite recently I realized that I have a very old c++98 standard, but how so? I seem to be writing in visual studio 2017, so where is c++17 or c++20? How do I upgrade to the new standard WITHOUT updating my IDE until 2019? You can tell us more about this in more detail.

#include <iostream>

int main()
{
    std::cout << __cplusplus;
    return 0;
}

I collect this code and get this on the output:Conclusion 199711

Author: Harry, 2020-07-03

2 answers

In Visual Studio 2017, it is enough to specify the required standard (up to 17) in the command line-run cl /?, and you will see, in particular,

                           -ЯЗЫК-  

/std:<c++14|c++17|c++latest> стандартная версия C++
c++14 - ISO/IEC 14882:2014 (по умолчанию)
c++17 - ISO/IEC 14882:2017
c++latest - последний черновик стандарта (набор возможностей может быть изменен)

This key can be specified in the operating system itself in the environment variable CL, for example,

set CL=/std:c++latest

The corresponding settings are also available in the IDE. Menu Project - >Properties - >Configuration Properties->C / C++->Language - >C++Language Standard

As far as I remember, in the first releases of VC++ 2017 by default, C++11 was used, but I may be wrong. The latest version uses C++14 by default, but you can switch to C++17.

As for C++20-I'm afraid, in VC++ 2017-nothing ... Here you can find out what is from the standard and in which version of VC++ was implemented.

 4
Author: Harry, 2020-07-04 03:58:52

You are probably wrong about the current version of the standard - this macro by default reports about the availability of the current version for the sake of compatibility

Because lots of existing code appears to depend on the value of this
macro matching "199711L", the compiler does not change the value of
the macro unless you explicitly opt-in by using the /Zc:_

And to check the version using this macro, you need to enable the compiler option /Zc

When the /Zc:__cplusplus option is enabled, the value reported by the 
__cplusplus macro depends on the /std version switch setting.
 4
Author: MBo, 2020-07-03 18:11:46