This blog post written by Gabriel Dos Reis, Ulzii Luvsanbat, and Andrew Pardoe.
In Visual C++ 2015 Update 3 we are introducing tools to help you control the version of the ISO C++ programming language you depend on and the version you want VC++ to enforce in your projects. We’re creating a series of new switches that correspond to versions of the C++ language, starting with
Why add these switches?
Traditionally, we would release the compiler in a default mode that combines features striding several versions of the C++ language, e.g. C++98, C++03, C++11, C++14, etc. in addition to conformance improvement bug fixes. This can lead to situations where it is difficult to simultaneously upgrade to the newer and better compiler and at the same time move your code forward. We really appreciate the great feedback you’ve given us about our conformance improvements and new feature work. As the C++ standards committee is gearing up for a new C++ version, we’ve taken the initiative to help you state in your build systems or compiler command lines which version of C++ you are comfortable with while updating to the next version of Visual C++.
Visual C++ has made significant progress towards C++ standards conformance between the first release of Visual Studio 2015 and VS 2015 Update 3. We’ve fixed many issues with
constexpr, improved expression SFINAE support, evaluation of initializer lists, variable templates, and more. Our standard library implementation has kept pace with features adopted into the post-C++14 standard draft. And we’ve implemented some major features currently under consideration by the committee, including C++ modules and coroutines. We want you to benefit from all this, but also we want you to consume these features at your own pace, while upgrading to this new update.
All post-C++14 features implemented in this update are off by default; those which were included in previous releases are left on to avoid causing your builds.
Switches for language versions
We want to help you keep your compiler toolchains up to date with the newest versions of Visual Studio. To help you stay current without requiring you to immediately move your code to the latest C++ standards we’re introducing a series of switches that allow you to opt-in to versions of the C++ standard. As we’re starting with VS 2015 Update 3, the first switch in the series will be
/std:c++14, reflecting the state of the Visual C++ compiler today. We also introduce a
/std:c++latest switch that will reflect compiler and library work proposed in the current standard draft. Note that similar switches are available in other compilers, including GCC and Clang.
The switches enable new features from each C++ Standard, or any behavior breaking changes on existing features. They are not meant to track MSVC-specific conformance bugs. Bug fixes will continue to happen independently of language version switches. If a bug fix prompts source code changes to be more standards conformant, the compiler will provide well-defined diagnostic messages. And we’ll continue to keep an extremely high bar for bug fixes that require source code changes, and we’ll continue to document each fix and its impact (this page lists the existing compiler conformance improvements documentation for VS 2015.)
/std:c++14 switch enables the set of C++14 features implemented by the Visual C++ compiler, modulo conformance bug fixes and ongoing feature work (such as for constexpr, expression SFINAE, 2-phase name lookup, etc.) Using the /std:c++14 switch will always instruct Visual C++ to compile your code according to the C++14 standards and associated Defect Reports. This is the default language version in this update.
Each version of the C++ Standard generally builds upon previous versions, except when they don’t. Consequently, each language version (for versions after C++14, because we are starting with
/std:c++14) will select C++14 semantics in addition to any other requirements (including feature modification or removal) instructed by that language version. Using a later switch in the series such as
/std:c++latest (see the section on
/std:c++latest below) will turn on post-C++14 features in addition to C++14 features. Note that there is no plan to add a C++11 switch.
There are some post-C++14 features already implemented in previous releases of the Visual C++ compiler. To avoid breaking changes for users who have already taken dependencies on these features we’ll leave them under the
/std:c++14 switch. They include the following features, all of which have already shipped in Visual Studio 2015 Update 2:
- New rules for auto with braced-init-lists
- typename in template template-parameters
- Removing trigraphs
- Attributes for namespaces and enumerators
- u8 character literals
/std:c++latest switch will move forward the set of features implemented by Visual C++ with each new version of the C++ standards Working Draft. Currently it will track features that we add for the proposed post-C++14 draft standard. When the next standard is approved, the semantics opted-in with the
/std:c++latest will be covered by
/std:c++17 (assuming that the next standard is C++17, but the standards committee working group never ceases to surprise) and
/std:c++latest will move forward to track the next draft standard’s features. In another words, with /std:c++latest, you will always get the set of all new features currently implemented and on by default. (The
/std:c++latest switch will not turn on new features guarded by the
Visual Studio 2015 Update 3 introduces two new switches (
/std:c++latest) to give you control over the version of the C++ programming language you want to use in your projects. In this update, if you specify a language version that isn’t any of those, the compiler will ignore the switch (with a warning) and default to C++14. You can try the compiler out today–see this blog post for details on how to get the VS 2015 Update 3 RC: https://blogs.msdn.microsoft.com/visualstudio/2016/06/07/visual-studio-2015-update-3-rc/
As always, we’re eager for you to try out the changes and give us feedback in the comments below, by email at email@example.com, or through any of the usual channels: User Voice, Suggestions, Connect (for bugs), or even Send-A-Smile. We love hearing from you!