How do I use standard version flags (-std=...) with MSVC?

To use standard version flags (like -std=...) with Microsoft Visual C++ (MSVC), you will need to select the appropriate language version using the `/std` compiler option. This allows you to specify the C++ standard you want your code to comply with, such as C++11, C++14, C++17, or C++20.

Here’s how you can set the C++ standard in your projects:

  • For Visual Studio 2017 version 15.6 and later, you can choose the standard in your project's properties.
  • Navigate to Project Properties > C/C++ > Language > Language Standard, and select your desired standard.
  • You can also specify it from the command line using the `/std` option followed by the version you want.

Here’s an example of setting the C++ standard via the command line:

cl /std:c++17 my_program.cpp

standard version flags MSVC C++ standard Visual Studio C++11 C++14 C++17 C++20