C++11 Features in Visual Studio 2012

C++11 features in Visual Studio 2012

It's worth noting that Visual Studio 2010 already had quite a bit of early C++11 support. So to summarize what is already linked to in other answers, here is what is new in Visual Studio 11 that was not part of Visual Studio 2010:

  • rvalue references to version 2.1 from 2.0
  • lambdas to version 1.1 from 1.0.
  • decltype to version 1.1 from 1.0(not yet available in developer preview)
  • Improved, but still incomplete, Alignment
  • completed strongly-typed enums
  • forward declared enums
  • Standard layout and trivial types
  • Atomics
  • Strong compare and exchange
  • Bi-directional fences
  • Data-dependency ordering
  • Range-based for loop

In early November 2012, Microsoft announced the Visual C++ Compiler November 2012 CTP, which adds more C++11 functionality to Visual Studio 2012:

  • uniform initialization
  • initializer lists
  • variadic templates
  • function template default arguments
  • delegating constructors
  • explicit conversion operators
  • raw strings

Disabling C++11 features on VS2012

As of Visual C++ 2015 Update 3, it is now possible to specify a language version for language behavior (apparently it doesn't affect just conformance checking):

https://blogs.msdn.microsoft.com/vcblog/2016/06/07/standards-version-switches-in-the-compiler/

Unfortunately the only options are "C++14" (not exact, it includes post-C++14 features which had previously shipped) and "C++ Latest" (C++14 plus partial implementation of C++17 and proposals, but not "experimental" features)

The corresponding command line switches are:

  • /std:c++14
  • /std:c++latest

Visual Studio 2012 __cplusplus and C++ 11

This has already been submitted to Microsoft for review:

A value of predefined macro __cplusplus is still 199711L

Array in C++ 11

According to this page on MSDN that Visual Studio 2012 does not support initialiser lists but 2013 does.

Manually set C++ language version for Visual Studio 2012

Sort of.

Microsoft sort of decides for itself what it will use in each version. For example Visual Studio 2010 was mostly a C++03 animal but you could use some C++11 features like auto.

Anyway the way you'd switch to Visual Studio 2010's compiler (or some other supported version) would be in your project's property pages: "Configuration Properties" > "General" > "Platform Toolset"

Then just pick the version you want to use.

Why doesn't VS2012 recognize certain C++11 keywords in a C++ project?

Support of C++11 in VS 2012 as you see is incomplete. The keyword list you provide looks like matching the unimplemented stuff.

Visual express c++ with C++11 and threads support

To get support for Visual Studio Express you either need Visual Studio Express 2012, or you can purchase my Just::Thread library, which provides the C++11 thread library for MSVC 2005 and later on Windows, and various versions of gcc across Windows, Linux and MacOSX.

Does MS Visual Studio 2012 Update 2 compile C++11 raw string literals?

The November CTP was not for Update 1, it was for "some unspecified future update".

Now Update 2 has been released, which contains nothing relevant to C++11.

The November CTP might eventually be released as Update 3.

Or it could be Update 4, or perhaps Update 14. Microsoft clearly isn't in a hurry. But outside of the CTP, these C++11 features are not yet supported by MSVC in Update 2 or earlier.



Related Topics



Leave a reply



Submit