VS2015预览版中的C++11/14/17 的特性

[原文发表地址] C++  11/14/17 Features In VS 2015 Preview

[原文发表时间] 2014/11/17 5:59 PM

Visual Studio 2015 预览版已经发布,所以这里给出一个预览版本关于核心语言的特性升级列表:

C++11核心语言特性

VS 2013 

   VS 2015预览版    

  说明

Rvalue references

部分

是

 

ref-qualifiers

否

是

 

Non-static data member initializers

部分

部分

[1]

Variadic templates

是

是

 

Initializer lists

部分

部分

[1]

static_assert

是

是

 

auto

是

是

 

Trailing return types

是

是

 

Lambdas

是

是

 

decltype

是

是

 

Right angle brackets

是

是

 

Default template args for function templates

是

是

 

Expression SFINAE

否

否

 

Alias templates

是

是

 

Extern templates

是

是

 

nullptr

是

是

 

Strongly typed enums

是

是

 

Forward declared enums

是

是

 

Attributes

否

否

 

constexpr

否

部分

[2]

Alignment

部分

是

 

Delegating constructors

是

是

 

Inheriting constructors

否

是

 

Explicit conversion operators

是

是

 

char16_t and char32_t

否

是

[新增]

Unicode string literals

否

是

[新增]

Raw string literals

是

是

 

Universal character names in literals

否

否

 

User-defined literals

否

是

 

Standard-layout and trivial types

是

是

 

Defaulted and deleted functions

部分

是

 

Extended friend declarations

是

是

 

Extended sizeof

否

是

 

Inline namespaces

否

是

 

Unrestricted unions

否

是

 

Local and unnamed types as template args

是

是

 

Range-based for-loop

是

是

 

override and final

是

是

 

Minimal GC support

是

是

 

noexcept

否

是

 

C++11核心语言特性 :   并发

VS 2013

VS 2015预览版

说明

Reworded sequence points

是

是

[3]

Atomics

是

是

 

Strong compare and exchange

是

是

 

Bidirectional fences

是

是

 

Memory model

是

是

[3]

Data-dependency ordering

是

是

 

Data-dependency ordering: attributes

否

否

 

exception_ptr

是

是

 

quick_exit and at_quick_exit

否

是

 

Atomics in signal handlers

否

否

 

Thread-local storage

部分

是

 

Magic statics

否

是

 

C++11核心语言特性 : C99

VS 2013

VS 2015预览版

说明

__func__

部分

是

 

C99 preprocessor

部分

部分

[4]

long long

是

是

 

Extended integer types

N/A

N/A

[5]

C++14核心语言特性

VS 2013

VS 2015预览版

说明

Tweaked wording for contextual conversions

是

是

[6]

Binary literals

否

是

[新增]

auto and decltype(auto) return types

否

是

 

init-captures

否

是

 

Generic lambdas

否

是

[新增]

Variable templates

否

否

 

Extended constexpr

否

否

 

NSDMIs for aggregates

否

否

 

Avoiding/fusing allocations

否

否

 

[[deprecated]] attributes

否

否

 

Sized deallocation

否

部分

[7]

Digit separators

否

RTM

[8]

C++1z (C++17?) 核心语言特性

VS 2013

VS 2015预览版

说明

New rules for auto with braced-init-lists

否

否

[9]

Terse static_assert

否

否

 

typename in template template-parameters

否

否

 

Removing trigraphs

是

是

[10]

Nested namespace definitions

否

否

 

N4259  std::uncaught_exceptions()

否

否

[11]

N4261 Fixing  qualification conversions

否

否

 

N4266 Attributes for  namespaces and enumerators

否

否

 

N4267 u8 character  literals

否

否

 

N4268 Allowing more  non-type template args

否

否

 

N4295 Fold expressions

否

否

 

说明:

[新增] 在VS 2015 CTP3特性列表 发布之后实现的特性。

[1] NSDMIs和initializer 之前状态是“是”, 但已经被降级为“部分”。 当用户在用到NSDMIs和mem-initializer-lists里面的braced-init-lists而导致编译失败的时候,编译器组会中断这些错误情景并给出一个C2797的编译错误。这篇今年八月发表的博客文章有更详细的信息。这个问题计划会在VS2015 RTM版本彻底的修正。

[2] C++11 constexpr支持依旧是“部分”;一个主要的限制是在标准库函数模板上它没有表现出“可选”行为。(例如,按标准来说,添加<T>的函数调用操作符被标为constexpr。这就允许添加<int>到一个常量表达式,再甚至添加<string>去分配内存,而对于常量表达式又完全是不对的。)其他的限制有:“Literal Class types”是“部分”地支持,“Array Literals”和“Aggregate Literals”目前还不支持,另外关于自动生成隐式定义默认构造函数的constexpr目前还没有实现。

[3] 我之前把C++11的“reworded sequence points”和“memory model”列为不适用,这令很多读者困惑。我现在把它们列为“是”,因为它们实际上已经实现了,虽然编译器组还没有为了它们做什么。(这些白皮书澄清C++11标准对多线程的交互,但是其实VC相比标准来说很早就支持了多线程。)

[4] C99preprocessor是“部分”支持。因为变长参数宏已经支持,但是编译器组意识到在这里有很多明显的bug。

[5] Extended integer types目前还不支持。实现是允许的,但是不要求有这样的类型,并且VC不支持它们。 这里说“是”或者“否”是不准确的,因此是“N/A”。

[6] 我们之前对“Tweaked wording for contextual conversions”是不支持的,但是现在支持了,并且VS2013和VS2015预览版都支持。在调查之后,我们发现这个特性抛弃了VC没有实现的过于严格的规则。嗯,一致了!

[7] Sized deallocation以前我们列举的是“是”,因为我错误相信仅仅是需要类库支持,以及编译器支持是可选的。 实际上,编译器支持是必须的,所以现在列举为“部分”。

[8] Digit separators已经实现了,但是它们还没有集成到预览版之后的分支里面。它们会在VS2015 RTM版本里面开始支持。

[9]“ new rules for auto with braced-init-lists”已经实现了并且差不多已经快要集成到产品。除非有什么意外,比如发现严重的问题或者委员会改变主意不支持以外,它们将在VS2015 RTM版本得到支持。

[10] VS2013和VS2015预览版默认都是禁止trigraphs。目前参照C++17去规划trigraphs。

[11] std::uncaught_exceptions() 被“荣誉地”列为核心语言特性,那是因为核心工作组通过投票通过的。我可能以后回改变对这个的支持。(其他的库特性例如exception_ptr也在这里罗列,但那只是由于为了容易地比较,我按照GCC的表格来列出。)

 

另外地白皮书N4262 “Wording forForwarding References”和N4285 “Cleanup for exception-specification and throw-expression” 已经入选进C++17标准,但是它们仅仅是编入而已,所以这里它们没有被罗列到这个特性表格。

 

Stephan T. Lavavej

高级开发工程师 - Visual C++类库团队

stl@microsoft.com