Visual Studio 2017Visual Studio 2017 中 Visual C++ 的新增功能What's New for Visual C++ in Visual Studio 2017Visual Studio 2017

Visual Studio 2017Visual Studio 2017 向 Visual C++ 环境引入了许多更新和修补程序。 brings many updates and fixes to the Visual C++ environment. 我们修复了编译器和工具中的 250 多个 bug 和已报告问题,其中很多是客户通过 Microsoft Connect 提交的。We've fixed over 250 bugs and reported issues in the compiler and tools, many submitted by customers through Microsoft Connect. 感谢你报告 bug!Thank you for reporting bugs! 有关整个 Visual Studio 中新增功能的详细信息,请访问 中的新增功能Visual Studio 2017Visual Studio 2017For more information on what's new in all of Visual Studio, please visit What's new in Visual Studio 2017Visual Studio 2017.

C++ 编译器C++ compiler

C++ 的符合性改进C++ conformance improvements

在此版本中,我们更新了 C++ 编译器和标准库,不仅增强了对 C++11 和 C++14 功能的支持,还初步提出了对预期推出的特定 C++17 标准功能的支持。In this release, we've updated the C++ compiler and standard library with enhanced support for C++11 and C++14 features, as well as preliminary support for certain features expected to be in the C++17 standard. 有关详细信息,请参阅 Visual Studio 2017 中 C++ 的符合性改进For detailed information, see C++ Conformance Improvements in Visual Studio 2017.

新的编译器开关New compiler switches

-/std:c++14/std:c++latest:这些编译器开关使你可以选择在项目中加入特定版本的 ISO C++ 编程语言。-/std:c++14 and /std:c++latest: These compiler switches enable you to opt-in to specific versions of the ISO C++ programming language in a project. 有关详细信息,请参阅 -std(指定语言标准版本)For more information, see -std (Specify Language Standard Version). 大多数新的草案标准功能由 /std:c++lates 开关保护。Most of the new draft standard features are guarded by the /std:c++latest switch.

Visual Studio 2017 版本 15.3/std:c++17 选项启用由 Visual C++ 编译器实现的一组 C++17 功能。Visual Studio 2017 version 15.3: The /std:c++17 option enables the set of C++17 features implemented by the Visual C++ compiler. 此选项禁用 C++ 标准的工作草案和缺陷更新的最新版本中已更改或新的功能的编译器和标准库支持。This option disables compiler and standard library support for features that are changed or new in more recent versions of the Working Draft and defect updates of the C++ Standard.

-/permissive-:启用所有严格标准符合性编译器选项,并禁用大部分特定于 Microsoft 的编译器扩展(但也有一些除外,例如 __declspec(dllimport))。-/permissive-: Enable all strict standards conformance compiler options and disable most Microsoft-specific compiler extensions (but not __declspec(dllimport), for example). (默认情况下为关,但在未来的某个时刻将默认为开。)(Off by default but will be on by default at some point in the future.)

-/diagnostics:启用显示行号、行号和列,或行号和列及脱字号(位于诊断错误或警告所在代码行的下方)。-/diagnostics: Enable display of the line number, the line number and column, or the line number and column and a caret under the line of code where the diagnostic error or warning was found.

-/debug:fastlink-/debug:fastlink:
通过避免将所有调试信息复制到 PDB 文件,实现最高达 30% 更快的增量链接时间(与Visual Studio 2015 相比)。Enable up to 30% faster incremental link times (vs. Visual Studio 2015) by not copying all debug information into the PDB file. PDB 文件改为指向用于创建可执行文件的对象和库文件的调试信息。The PDB file instead points to the debug information for the object and library files used to create the executable. 请参阅 Faster C++ build cycle in VS “15” with /Debug:fastlink(使用 /Debug:fastlink 在 VS “15” 中获得更快的生成周期)和 Recommendations to speed C++ builds in Visual Studio(在 Visual Studio 中加速 C++ 生成的建议)。See Faster C++ build cycle in VS “15” with /Debug:fastlink and Recommendations to speed C++ builds in Visual Studio.

Visual Studio 2017Visual Studio 2017 允许结合使用 /sdl 和 /await。 allows using /sdl with /await. 删除了协同程序的 /RTC 限制。We removed the /RTC limitation with Coroutines.

Visual Studio 2017 版本 15.5:Visual C++ 编译器支持 75% 的 C++17 功能,包括结构化绑定、constexpr lambda、if constexpr、内联变量、fold 表达式和将 noexcept 添加到类型系统。Visual Studio 2017 version 15.5: The Visual C++ compiler supports about 75% of C++17 features, including structured bindings, constexpr lambdas, if constexpr, inline variables, fold expressions, and adding noexcept to the type system. 这些功能在 /std:c++17 开关下可用。These are available under the /std:c++17 switch. /permissive- 符合性模式包括对两阶段名称查找的部分支持。The /permissive- conformance mode includes partial support for two-phase name lookup. 有关详细信息,请参阅 Visual Studio 2017 中 C++ 的符合性改进For more information, see C++ Conformance Improvements in Visual Studio 2017.

Codegen、安全性、诊断和版本控制Codegen, security, diagnostics and versioning

此版本在优化、代码生成、工具集版本控制和诊断方面做出了若干改进。This release brings several improvements in optimization, code generation, toolset versioning, and diagnostics. 显著改进包括:Some notable improvements include:

  • 改进了循环的代码生成:支持常量整数除法的自动矢量化,优化了 memset 模式的识别。Improved code generation of loops: Support for automatic vectorization of division of constant integers, better identification of memset patterns.
  • 提高了代码安全性:改进了缓冲区溢出编辑器诊断的显示,/guard:cf 现可保护生成转移表的切换语句。Improved code security: Improved emission of buffer overrun compiler diagnostics, and /guard:cf now guards switch statements that generate jump tables.
  • 版本控制:内置预处理器宏_MSC_VER 的值现在会在每次 Visual C++ 工具集更新时单调更新。Versioning: The value of the built-in preprocessor macro _MSC_VER is now being monotonically updated at every Visual C++ toolset update. 有关详细信息,请参阅 Visual C++ Compiler Version(Visual C++ 编译器版本)。For more information, see Visual C++ Compiler Version.
  • 新工具集布局:编译器和相关生成工具在开发计算机上有了新的位置和目录结构。New toolset layout: The compiler and related build tools have a new location and directory structure on your development machine. 新布局支持并行安装多个版本的编译器。The new layout enables side-by-side installations of multiple versions of the compiler. 有关详细信息,请参阅 Compiler Tools Layout in Visual Studio "15"(Visual Studio“15”中的编译器工具布局)。For more information, see Compiler Tools Layout in Visual Studio "15".
  • 改进了诊断:输出窗口现在会显示发生错误的列。Improved diagnostics: The output window now shows the column where an error occurs. 有关详细信息,请参阅 C++ compiler diagnostics improvements in VS “15” Preview 5(VS“15”预览版 5 中的 C++ 编译器诊断改进)。For more information, see C++ compiler diagnostics improvements in VS "15" Preview 5.
  • 使用协同程序时,实验关键字“yield”(在 /await switch 下可用)已被删除。When using co-routines, the experimental keyword "yield" (available under the /await switch) has been removed. 应更新代码,以改为使用 co_yieldYour code should be updated to use co_yield instead. 有关详细信息,请参阅 Visual C++ 团队博客For more information, see the Visual C++ Team blog.

Visual Studio 2017 版本 15.3:对编译器中的诊断进行的其他改进。Visual Studio 2017 version 15.3: Additional improvements to diagnostics in the compiler. 有关详细信息,请参阅 Visual Studio 2017 15.3.0 中的诊断改进For more information, see Diagnostic Improvements in Visual Studio 2017 15.3.0.

Visual Studio 2017 版本 15.5:由于生成的代码质量更好,Visual C++ 运行时的性能继续改进。Visual Studio 2017 version 15.5: Visual C++ runtime performance continues to improve due to better generated code quality. 这意味着可以只是重新编译代码,应用即可更快速地运行。This means that you can simply recompile your code, and your app just runs faster. 某些编译器的优化是全新的,例如条件标量存储的矢量化、将 sin(x) 和 cos(x) 调用合并到新的 sincos(x) 中以及从 SSA 优化器中消除多余的说明。Some of the compiler optimizations are brand new, such as the vectorization of conditional scalar stores, the combining of calls sin(x) and cos(x) into a new sincos(x), and the elimination of redundant instructions from the SSA Optimizer. 其他编译器优化是对现有功能的改进,例如条件表达式的矢量器启发、更佳的循环优化和浮动最小/最大 codegen。Other compiler optimizations are improvements to existing functionality such as vectorizer heuristics for conditional expressions, better loop optimizations, and float min/max codegen. 链接器的新 /OPT:ICF 实现速度更快,可以使链接时间最多加快 9%,并且“增量链接”中有其他性能修复。The linker has a new and faster /OPT:ICF implementation which can result in up to 9% link time speedups, and there are other perf fixes in "incremental linking". 有关详细信息,请参阅 /OPT(优化)/INCREMENTAL(增量链接)For more information, see /OPT (Optimizations) and /INCREMENTAL (Link Incrementally).

Visual C++ 支持 Intel AVX-512,包括将 AVX-512 中的新函数引入位宽为 128 和 256 的寄存器的向量长度说明。Visual C++ supports Intel's AVX-512, including the Vector Length instructions that bring new functions in AVX-512 to 128- and 256-bit wide registers.

通常使用 C++17 模式时,可以使用“/Zc:noexceptTypes-”开关转换到 noexcept 的 C++14 版本。The /Zc:noexceptTypes- switch can be used to revert to the C++14 version of noexcept while using C++17 mode in general. 这样可以将源代码更新为符合 C++17,而无需在同时重写所有 throw() 代码。This enables you to update your source code to conform to C++17 without having to rewrite all your throw() code at the same time. 有关详细信息,请参阅动态异常规范删除和 noexceptFor more information, see Dynamic exception specification removal and noexcept.

C++ 标准库改进C++ Standard Library improvements

  • 对 basic_string _ITERATOR_DEBUG_LEVEL != 0 诊断进行了小幅改进。Minor basic_string _ITERATOR_DEBUG_LEVEL != 0 diagnostics improvements. 在字符串机制中进行 IDL 检查现在将报告触发该检查的特定行为。Tripping an IDL check in string machinery will now report the specific behavior that caused the trip. 例如,现在会收到“无法取消引用字符串迭代器,因为其已超出范围(例如末尾迭代器)”,而不是“字符串迭代器不可取消引用”。For example, instead of "string iterator not dereferencable" you'll get "cannot dereference string iterator because it is out of range (e.g. an end iterator)".
  • 性能改进:basic_string::find(char) 重载仅调用 traits::find 一次。Performance improvement: made basic_string::find(char) overloads only call traits::find once. 以前会将此操作实施为针对长度为 1 的字符串的常规字符串搜索。Previously this was implemented as a general string search for a string of length 1.
  • 性能改进:basic_string::operator== 现会在比较字符串内容之前检查字符串的大小。Performance improvement: basic_string::operator== now checks the string's size before comparing the strings' contents.
  • 性能改进:删除了 basic_string 中编译器优化程序难以分析的控制耦合。Performance improvement: removed control coupling in basic_string which was difficult for the compiler optimizer to analyze. 解决了 VSO# 262848“<string>: reserve() 执行了过多操作”。Resolves VSO# 262848 "<string>: reserve() does too much work". 请注意,对于所有短字符串,调用 reserve 后即使不执行任何操作仍会耗用资源。Note that for all short strings, calling reserve still has nonzero cost to do nothing.
  • 我们添加了 <any>、<string_view>、apply()、make_from_tuple()。We added <any>, <string_view>, apply(), make_from_tuple().
  • 对 std:: vector 进行了全面改进以提高正确性和性能:现可按标准版的要求正确处理插入/定位期间的别名化,在标准版需要时可通过 move_if_noexcept() 和其他逻辑提供强大的异常保障,并且插入/定位执行的元素操作减少。std::vector has been overhauled for correctness and performance: aliasing during insertion/emplacement is now correctly handled as required by the Standard, the strong exception guarantee is now provided when required by the Standard via move_if_noexcept() and other logic, and insertion/emplacement perform fewer element operations.
  • 现在 C++ 标准库会避免取消引用 null 复杂精致指针。The C++ Standard Library now avoids dereferencing null fancy pointers.
  • 增添了 <optional>、<variant>、shared_ptr::weak_type 和 <cstdalign>。Added <optional>, <variant>, shared_ptr::weak_type, and <cstdalign>.
  • 在 min/max/minmax(initializer_list) 和 min_element/max_element/minmax_element() 中启用了 C++14 constexpr。Enabled C++14 constexpr in min/max/minmax(initializer_list) and min_element/max_element/minmax_element().
  • 改进了 weak_ptr::lock() 性能。Improved weak_ptr::lock() performance.
  • 修复了 std::promise 的移动赋值运算符,该运算符之前可导致代码永久受阻。Fixed std::promise's move assignment operator, which previously could cause code to block forever.
  • 修复了编译器错误,将 atomic<T *> 隐式转换为 T *。Fixed compiler errors with atomic<T *>'s implicit conversion to T *.
  • pointer_traits<Ptr> 现可正确检测 Ptr::rebind<U>。pointer_traits<Ptr> now correctly detects Ptr::rebind<U>.
  • 修复了 move_iterator 减法运算符中缺少的 const 限定符。Fixed a missing const qualifier in move_iterator's subtraction operator.
  • 针对需要 propagate_on_container_copy_assignment 和 propagate_on_container_move_assignment 的有状态用户定义的分配器,修复了无提示的错误代码生成。Fixed silent bad codegen for stateful user-defined allocators requesting propagate_on_container_copy_assignment and propagate_on_container_move_assignment.
  • atomic<T> 现可容忍重载的 operator&()。atomic<T> now tolerates overloaded operator&().
  • 为提高编译器吞吐量,C++ 标准库标头现不会包含非必需编译器内部函数的声明。To increase compiler throughput, C++ Standard Library headers now avoid including declarations for unnecessary compiler intrinsics.
  • 略微改进了针对错误的 bind() 调用的编译器诊断。Slightly improved compiler diagnostics for incorrect bind() calls.
  • 将 std::string/std::wstring 的移动构造函数的性能提升了超过 3 倍Improved the performance of std::string/std::wstring's move constructors by more than 3x
  • 有关标准库改进的完整列表,请参阅 VS 2017 RTM 中的标准库修复For a complete list of Standard Library improvments see the Standard Library Fixes In VS 2017 RTM.

Visual Studio 2017 版本 15.3Visual Studio 2017 version 15.3

C++17 功能C++17 features

已经实现了几个其他的 C++17 功能。Several additional C++17 features have been implemented. 有关详细信息,请参阅 Visual C++ 语言一致性For more information, see Visual C++ Language Conformance.

其他新增功能Other new features

  • 实现了 P0602R0“变体和可选项应传播副本/移动琐碎事项”。Implemented P0602R0 "variant and optional should propagate copy/move triviality".
  • 现在,标准库正式允许通过 /GR- 禁用动态 RTTI。The Standard Library now officially tolerates dynamic RTTI being disabled via /GR-. dynamic_pointer_cast() 和 rethrow_if_nested() 本质上需要 dynamic_cast,因此标准库现在将它们在 /GR- 下标记为 =delete。dynamic_pointer_cast() and rethrow_if_nested() inherently require dynamic_cast, so the Standard Library now marks them as =delete under /GR-.
  • 即使已通过 /GR- 禁用了动态 RTTI,“静态 RTTI”(采用 typeid(SomeType) 形式)仍可用,并为多个标准库组件提供支持。Even when dynamic RTTI has been disabled via /GR-, "static RTTI" (in the form of typeid(SomeType)) is still available and powers several Standard Library components. 现在,标准库也支持通过 /D_HAS_STATIC_RTTI=0 禁用此功能。The Standard Library now supports disabling this too, via /D_HAS_STATIC_RTTI=0. 请注意,这将禁用 std::any、std::function 的 target()、target_type() 和 shared_ptr 的 get_deleter()。Note that this will disable std::any, std::function's target() and target_type(), and shared_ptr's get_deleter().

正确性修复Correctness fixes

  • 现在,标准库容器将其 max_size() 绑定到numeric_limits<difference_type>::max() 而不是 size_type 的最大值。这确保来自该容器的迭代器上的 distance() 的结果在 distance() 的返回类型中是可表示的。Standard Library containers now clamp their max_size() to numeric_limits<difference_type>::max() rather than size_type's max. This ensures that the result of distance() on iterators from that container is representable in the return type of distance().
  • 修复了缺少的指定 auto_ptr<void>。Fixed missing specialization auto_ptr<void>.
  • 如果 length 参数不是整数类型,则以前无法编译 meow_n() 算法;现在它们尝试将非整数长度转换为迭代器的 difference_type。The meow_n() algorithms previously failed to compile if the length argument was not an integral type; they now attempt to convert non-integral lengths to the iterators' difference_type.
  • normal_distribution<float> 不再在标准库中发出关于从双精度型收缩为浮点型的警告。normal_distribution<float> no longer emits warnings inside the Standard Library about narrowing from double to float.
  • 修复了一些 basic_string 操作,这些操作在检查最大大小溢出时与 npos 而不是 max_size() 进行比较。Fixed some basic_string operations which were comparing with npos instead of max_size() when checking for maximum size overflow.
  • condition_variable::wait_for(lock, relative_time, predicate) 将在发生虚假唤醒时等待整个相对时间。condition_variable::wait_for(lock, relative_time, predicate) would wait for the entire relative time in the event of a spurious wake. 现在,它将仅等待单个相对时间间隔。Now, it will wait for only a single interval of the relative time.
  • future::get() 现在将根据标准要求使未来无效。future::get() now invalidates the future, as the standard requires.
  • iterator_traits<void *> 曾经是一个硬错误,因为它尝试形成 void&;,它现在完全变成了一个空结构,以允许在“is iterator”SFINAE 条件中使用 iterator_traits。iterator_traits<void *> used to be a hard error because it attempted to form void&; it now cleanly becomes an empty struct to allow use of iterator_traits in "is iterator" SFINAE conditions.
  • 修复了 Clang -Wsystem-headers 报告的一些警告。Some warnings reported by Clang -Wsystem-headers were fixed.
  • 还修复了 Clang -Wmicrosoft-exception-spec 报告的“声明中的异常规范与以前的声明不匹配”。Also fixed "exception specification in declaration does not match previous declaration" reported by Clang -Wmicrosoft-exception-spec.
  • 还修复了 Clang 和 C1XX 报告的 mem-initializer-list 排序警告。Also fixed mem-initializer-list ordering warnings reported by Clang and C1XX.
  • 当容器本身交换时,无序容器不会交换其哈希计算器或谓词。The unordered containers did not swap their hashers or predicates when the containers themselves were swapped. 现在它们会进行交换。Now they do.
  • 现在,许多容器交换操作被标记为 noexcept(因为我们的标准库从未打算在检测到 non-propagate_on_container_swap non-equal-allocator 未定义的行为条件时引发异常)。Many container swap operations are now marked noexcept (as our Standard Library never intends to throw an exception when detecting the non-propagate_on_container_swap non-equal-allocator undefined behavior condition).
  • 许多 vector<bool> 操作现在被标记为 noexcept。Many vector<bool> operations are now marked noexcept.
  • 标准库现在将使用选择退出的转义交错线来强制执行匹配的分配器 value_types(在 C++17 模式中)。The Standard Library will now enforce matching allocator value_types (in C++17 mode) with an opt-out escape hatch.
  • 修复了一些将 self-range 插入 basic_strings 会打乱字符串内容的情况。Fixed some conditions where self-range-insert into basic_strings would scramble the strings' contents. (注意:标准库仍禁止将 self-range 插入到矢量)。(Note: self-range-insert into vectors is still prohibited by the Standard.)
  • basic_string::shrink_to_fit() 不再受分配器的 propagate_on_container_swap 的影响。basic_string::shrink_to_fit() is no longer affected by the allocator's propagate_on_container_swap.
  • std::decay 现在可以处理令人厌恶的函数类型(即 cv 限定和/或引用限定的函数类型)。std::decay now handles abominable function types (i.e. function types that are cv-qualified and/or ref-qualified).
  • 更改了 include 指令以正确使用区分大小写和正斜杠,从而提高可移植性。Changed include directives to use proper case sensitivity and forward slashes, improving portability.
  • 修复了警告 C4061“枚举‘Kitten’的 switch 中的枚举器‘Meow’未按 case 标签进行显式处理”。Fixed warning C4061 "enumerator 'Meow' in switch of enum 'Kitten' is not explicitly handled by a case label". 此警告默认关闭,并且已作为警告的标准库的常规策略的一个异常进行了修复。This warning is off-by-default and was fixed as an exception to the Standard Library's general policy for warnings. (标准库是 /W4 清理,但并不会试图成为 /Wall 清理。(The Standard Library is /W4 clean, but does not attempt to be /Wall clean. 许多默认关闭的警告会导致过多的干扰,不打算定期使用。)Many off-by-default warnings are extremely noisy and aren't intended to be used on a regular basis.)
  • 改进了 std::list 的调试检查。Improved std::list's debug checks. 列表迭代器现在检查 operator->(),而且 list::unique() 现在将迭代器标记为无效。List iterators now check operator->(), and list::unique() now marks iterators as invalidated.
  • 修复了元组中的 use-allocator 元编程。Fixed uses-allocator metaprogramming in tuple.

性能/吞吐量修复Performance/throughput fixes

  • 解决了与 noexcept 的交互,从而防止将 std::atomic 的实现内联到使用结构化异常处理 (SEH) 的函数中的问题。Worked around interactions with noexcept which prevented inlining std::atomic's implementation into functions that use Structured Exception Handling (SEH).
  • 更改了标准库的内部 _Deallocate() 函数,以优化为较小的代码,从而允许将其内联到更多的位置。Changed the Standard Library's internal _Deallocate() function to optimize into smaller code, allowing it to be inlined into more places.
  • 更改了 std::try_lock() 以使用包扩展,而不是递归。Changed std::try_lock() to use pack expansion instead of recursion.
  • 改进了 std::lock() 的死锁避免算法以使用 lock() 操作,而不是在所有锁的 try_lock() 上旋转。Improved std::lock()'s deadlock avoidance algorithm to use lock() operations instead of spinning on all the locks' try_lock()s.
  • 启用了 system_category::message() 中的命名返回值优化。Enabled the Named Return Value Optimization in system_category::message().
  • 连接和析取现在实例化 N + 1 类型,而不是 2N + 2 类型。conjunction and disjunction now instantiate N + 1 types, instead of 2N + 2 types.
  • std::function 不再实例化每个类型擦除的可调用项的分配器支持机制,从而提高吞吐量,并缩减将许多不同的 lambda 传递给 std::function 的程序中的 .obj 大小。std::function no longer instantiates allocator support machinery for each type-erased callable, improving throughput and reducing .obj size in programs that pass many distinct lambdas to std::function.
  • allocator_traits<std::allocator> 包含手动内联的 std::allocator 操作,从而缩减仅通过 allocator_traits 与 std::allocator 交互的代码(即大多数代码)中的代码大小。allocator_traits<std::allocator> contains manually inlined std::allocator operations, reducing code size in code that interacts with std::allocator through allocator_traits only (i.e. most code).
  • C++11 最小分配器接口现在由标准库直接调用 allocator_traits 进行处理,而不是将分配器包装在内部类 _Wrap_alloc 中。The C++11 minimal allocator interface is now handled by the Standard Library calling allocator_traits directly, instead of wrapping the allocator in an internal class _Wrap_alloc. 这减少了为分配器支持生成的代码大小,提高了优化器在某些情况下对标准库容器进行推理的能力,并提供了更好的调试体验(正如现在看到了分配器类型,而不是调试器中的 _Wrap_alloc<你的分配器类型>)。This reduces the code size generated for allocator support, improves the optimizer's ability to reason about Standard Library containers in some cases, and provides a better debugging experience (as now you see your allocator type, rather than _Wrap_alloc<your allocator type> in the debugger).
  • 删除了自定义 allocator::reference 的元编程,实际上不允许自定义的分配器。Removed metaprogramming for customized allocator::reference, which allocators aren't actually allowed to customize. (分配器可以使容器使用设想的指针,但不可以使用设想的引用。)(Allocators can make containers use fancy pointers but not fancy references.)
  • 编译器前端已学会在基于范围的 for 循环中展开调试迭代器,从而提高调试版本的性能。The compiler front-end was taught to unwrap debug iterators in range-based for-loops, improving the performance of debug builds.
  • shrink_to_fit() 和 reserve() 的 basic_string 的内部收缩路径不再位于重新分配操作的路径中,从而减少所有转变成员的代码大小。basic_string's internal shrink path for shrink_to_fit() and reserve() is no longer in the path of reallocating operations, reducing code size for all mutating members.
  • basic_string 的内部增长路径不再位于 shrink_to_fit() 的路径中。basic_string's internal grow path is no longer in the path of shrink_to_fit().
  • basic_string 的转变操作现在已纳入到非分配快速路径和分配慢速路径函数,从而使其更有可能将常见的无重新分配的情况内联到调用方中。basic_string's mutating operations are now factored into non-allocating fast path and allocating slow path functions, making it more likely for the common no-reallocate case to be inlined into callers.
  • basic_string 的转变操作现在构造所需状态的重新分配缓冲区,而不是就地调整大小。basic_string's mutating operations now construct reallocated buffers in the desired state rather than resizing in place. 例如,在字符串的开头插入现在将在插入之后移动内容一次(向下移动或移动到新分配的缓冲区),而不是在重新分配的情况下移动两次(移动到新分配的缓冲区,然后向下移动)。For example, inserting at the beginning of a string now moves the content after the insertion exactly once (either down or to the newly allocated buffer), instead of twice in the reallocating case (to the newly allocated buffer and then down).
  • 在 <string> 中调用 C 标准库的操作现在缓存 errno 的地址以消除与 TLS 的重复交互。Operations calling the C standard library in <string> now cache errno's address to remove repeated interaction with TLS.
  • 简化了 is_pointer 的实现。Simplified is_pointer's implementation.
  • 完成了将基于函数的表达式 SFINAE 更改为基于 struct/void_t。Finished changing function-based Expression SFINAE to struct/void_t-based.
  • 标准库算法现在避免使用后增量迭代器。Standard Library algorithms now avoid postincrementing iterators.
  • 修复了在 64 位系统上使用 32 位分配器时的截断警告。Fixed truncation warnings when using 32-bit allocators on 64-bit systems.
  • 通过重复使用缓冲区(如果可能),在非 POCMA 非等分配器情况下,std::vector 移动赋值现在更高效。std::vector move assignment is now more efficient in the non-POCMA non-equal-allocator case, by reusing the buffer when possible.

可读性和其他改进Readability and other improvements

  • 标准库现在无条件地使用 C++14 constexpr,而不是有条件定义的宏。The Standard Library now uses C++14 constexpr unconditionally, instead of conditionally-defined macros.
  • 标准库现在内部使用别名模板。The Standard Library now uses alias templates internally.
  • 标准库现在内部使用 nullptr,而不是 nullptr_t{}。The Standard Library now uses nullptr internally, instead of nullptr_t{}. (已根除 NULL 的内部使用。(Internal usage of NULL has been eradicated. 正在逐渐清理 0 作为 null 的内部使用。)Internal usage of 0-as-null is being cleaned up gradually.)
  • 标准库现在内部使用 std::move(),而不是在风格上误用 std::forward()。The Standard Library now uses std::move() internally, instead of stylistically misusing std::forward().
  • 已将 static_assert(false, "message") 更改为 #error 消息。Changed static_assert(false, "message") to #error message. 这提高了编译器诊断,因为 #error 立即停止编译。This improves compiler diagnostics because #error immediately stops compilation.
  • 标准库不再将函数标记为 __declspec(dllimport)。The Standard Library no longer marks functions as __declspec(dllimport). 新式链接器技术不再需要此操作。Modern linker technology no longer requires this.
  • 已将 SFINAE 提取到默认模板参数,与返回类型和函数参数类型相比,这可以减少混乱。Extracted SFINAE to default template arguments, which reduces clutter compared to return types and function argument types.
  • <random> 中的调试检查现在使用标准库的常用机制,而不是使用将 fputs() 调用到 stderr 的内部函数 _Rng_abort()。Debug checks in <random> now use the Standard Library's usual machinery, instead of the internal function _Rng_abort() which called fputs() to stderr. 保留此函数的实现以实现二进制兼容性,但在标准库的下一个二进制不兼容版本中已删除。This function's implementation is being retained for binary compatibility, but has been removed in the next binary-incompatible version of the Standard Library.

Visual Studio 2017 版本 15.5Visual Studio 2017 version 15.5

已按照 C++17 标准添加、弃用或删除多个标准库功能。Several Standard Library features have been added, deprecated or removed in accordance with the C++17 standard. 有关详细信息,请参阅 Visual Studio 中 C++ 的符合性改进For more information see C++ conformance improvements in Visual Studio.

新实验性功能New experimental features

  • 以下并行算法的实验支持:Experimental support for the following parallel algorithms:
    • all_ofall_of
    • any_ofany_of
    • for_eachfor_each
    • for_each_nfor_each_n
    • none_ofnone_of
    • reducereduce
    • replacereplace
    • replace_ifreplace_if
    • sortsort
  • 添加了以下并行算法的签名,但暂不并行;分析显示仅移动或重新排列元素的并行算法并无益处:The signatures for the following parallel algorithms are added but not parallelized at this time; profiling showed no benefit in parallelizing algorithms that only move or permute elements:
    • copycopy
    • copy_ncopy_n
    • fillfill
    • fill_nfill_n
    • 移动move
    • reversereverse
    • reverse_copyreverse_copy
    • rotaterotate
    • rotate_copyrotate_copy
    • swap_rangesswap_ranges

性能修复和改进Performance fixes and improvements

  • basic_string<char16_t> 现在加入 basic_string<wchar_t> 加入的 memcmp/memcpy/etc. 优化。basic_string<char16_t> now engages memcmp/memcpy/etc. optimizations that basic_string<wchar_t> engages.
  • 已暂时避开阻止函数指针被 Visual Studio 2015 Update 3 的“避免复制函数”工作内联公开的优化器限制,从而还原 lower_bound(iter, iter, function pointer) 的性能。An optimizer limitation which prevented function pointers from being inlined exposed by our "avoid copying functions" work in Visual Studio 2015 Update 3 has been worked around, restoring performance of lower_bound(iter, iter, function pointer).
  • 将迭代器解包后再检查顺序,降低了向 includes、set_difference、set_symmetric_difference 和 set_union 的输入执行迭代器调试顺序验证的开销。The overhead of iterator debugging's order verification of inputs to includes, set_difference, set_symmetric_difference, and set_union was reduced by unwrapping iterators before checking order.
  • std::inplace_merge 现在跳过已就位的元素。std::inplace_merge now skips over elements that are already in position.
  • 构造 std::random_device 不再构造 std::string,然后再销毁它。Constructing std::random_device no longer constructs and then destroys a std::string.
  • std::equal 和 std::partition 有跳转线程优化传递,可以免去一次迭代器比较。std::equal and std::partition had a jump-threading optimization pass which saves an iterator comparison.
  • 当 std::reverse 将指针传递到完全可复制的 T 时,它将分派至一个手写的矢量化实现。When std::reverse is passed pointers to trivially copyable T, it will now dispatch to a handwritten vectorized implementation.
  • 训练了 std::fill、std::equal 和 std::lexicographical_compare 如何分派到 std::byte 和 gsl::byte(以及其他 char-ish enums 和 enum 类)的 memset / memcmp。std::fill, std::equal, and std::lexicographical_compare were taught how to dispatch to memset / memcmp for std::byte and gsl::byte (and other char-ish enums and enum classes). 请注意,std::copy 分派使用 is_trivially_copyable,因此不需要任何更改。Note that std::copy dispatches using is_trivially_copyable and thus didn't need any changes.
  • STL 不再包含仅有的行为是使类型不完全易损坏的空大括号析构函数。The STL no longer contains empty-braces destructors whose only behavior was to make types non-trivially-destructible.

正确性修复Correctness fixes

  • 按标准的要求,std::partition 现在调用谓词 N 次而不是 N + 1 次。std::partition now calls the predicate N times instead of N + 1 times, as the standard requires.
  • 已在 15.5 中修复 15.3 中避免神奇的静态对象的尝试。Attempts to avoid magic statics in 15.3 have been repaired in 15.5.
  • std::atomic<T> 不再需要 T 默认可构造。std::atomic<T> no longer requires T to be default constructible.
  • 启用了迭代器调试时,需耗用对数时间的堆算法不再进行“输入实际为堆”的线性时间断言。Heap algorithms that take logarithmic time no longer do a linear time assertion that the input is in fact a heap when iterator debugging is enabled.
  • 现在,仅为 C1XX 保护 __declspec(allocator),防止出现来自不了解此 declspec 的 Clang 的警告。__declspec(allocator) is now guarded for C1XX only, to prevent warnings from Clang which doesn't understand this declspec.
  • basic_string::npos 现在可作为编译时常数提供。basic_string::npos is now available as a compile time constant.
  • std::allocator 现在正确处理过度对齐的类型的分配,在 C++17 模式中这些类型的对齐高于 max_align_t(除非由 /Zc:alignedNew- 禁用)。std::allocator now properly handles allocation of over-aligned types - types whose alignment is greater than max_align_t – in C++17 mode (unless disabled by /Zc:alignedNew-). 例如,对于 SSE/AVX 说明,现在将正确对齐采用 16 或 32 字节对齐的对象的矢量。For example, vectors of objects with 16 or 32-byte alignment will now be properly aligned for SSE / AVX instructions.

其他库Other Libraries

开源库支持Open source library support

Vcpkg 是一款开源命令行工具,能极大简化在 Visual Studio 中获取和生成开源 C++ 静态库和 DLLS 的过程。Vcpkg is an open-source command line tool that greatly simplifies the process of acquiring and building open source C++ static libs and DLLS in Visual Studio. 有关详细信息,请参阅 vcpkg:用于 C++ 的程序包管理器 For more information, see vcpkg: A package manager for C++.

Visual Studio 2017 版本 15.5Visual Studio 2017 version 15.5

CPPRest SDK 2.9.0CPPRest SDK 2.9.0

CPPRestSDK(C++ 的跨平台 Web API)已更新到版本 2.9.0。The CPPRestSDK, a cross-platform web API for C++, has been updated to version 2.9.0. 有关详细信息,请参阅 CppRestSDK 2.9.0 is available on GitHub(GitHub 上提供了 CppRestSDK 2.9.0)。For more information, see CppRestSDK 2.9.0 is available on GitHub.

ATLATL

  • 另外进行了另一组名称查找符合性修复Yet another set of name-lookup conformance fixes
  • 现有的移动构造函数和移动赋值运算符现已正确地标记为非引发Existing move constructors and move assignment operators are now properly marked as non-throwing
  • 取消禁止有关 atlstr.h 中本地静态变量的线程安全初始化的有效警告 C4640Un-suppress valid warning C4640 about thread safe init of local statics in atlstr.h
  • 在 [使用 ATL 和生成 DLL] 时,本地静态变量的线程安全初始化会在 XP 工具集中自动关闭。Thread Safe Initialization of local statics was automatically turned off in the XP toolset when [using ATL AND building a DLL]. 这种情况不会再出现。This is no longer the case. 如果需要关闭线程安全初始化,则可以在项目设置中添加 /Zc:threadSafeInit-。You can add /Zc:threadSafeInit- in your Project settings if having thread safe initialization off is desired.

Visual C++ 运行时Visual C++ runtime

  • 为控制流防护符号新增了标头“cfguard.h”。New header "cfguard.h" for Control Flow Guard symbols.

C++ IDEC++ IDE

  • 现针对 C++ 本机项目和 C++ /CLI 项目有了更佳的配置更改性能,后者的性能增加更为明显。Configuration change performance is now better for C++ native projects and much better for C++/CLI projects. 第一次激活解决方案配置时,现在的速度会更快,且此解决方案配置的所有后续激活几乎可瞬时完成。When a solution configuration is activated for the first time it will now be faster and all subsequent activations of this solution configuration will be almost instantaneous.

Visual Studio 2017 版本15.3Visual Studio 2017 version 15.3:

  • 多个项目和代码向导已按照签名对话框样式重新编写。Several project and code wizards have been rewritten in the signature dialog style.
  • “添加类”现在直接启动“添加类向导”。Add Class now launches the Add Class wizard directly. 以前此处的其他所有项现在位于“添加”>“新建项”。All of the other items that were previously here are now available under Add > New Item.
  • Win32 项目现在位于“新建项目”对话框中的“Windows 桌面”类别下。Win32 projects are now under the Windows Desktop category in the New Project dialog.
  • Windows 控制台和桌面应用程序模板现在可以在不显示向导的情况下创建项目。The Windows Console and Desktop Application templates now create the projects without displaying a wizard. 现在,在相同的类别下有一个新的 Windows 桌面向导,显示和以前相同的选项。There's a new Windows Desktop Wizard now under the same category that displays the same options as before.

Visual Studio 2017 版本 15.5:多种使用 IntelliSense 引擎重构和导航代码的 C++ 操作运行速度更快。Visual Studio 2017 version 15.5: Several C++ operations that use the IntelliSense engine for refactoring and code navigation run much faster. 以下数字基于有 3500 个项目的 Visual Studio Chromium 解决方案:The following numbers are based on the Visual Studio Chromium solution with 3500 projects:

功能Feature 性能改进Performance Improvement
重命名Rename 5.3 倍5.3x
更改签名Change Signature 4.5 倍4.5x
查找所有引用Find All References 4.7 倍4.7x

C++ 现在支持通过“Ctrl+单击”转到定义,使利用鼠标导航到定义更轻松。C++ now supports Ctrl+Click GoTo Definition, making mouse navigation to definitions easy. Productivity Power Tools 包的结构可视化工具现在也默认包含在产品中。The Structure Visualizer from the Productivity Power Tools pack is now also included in the product by default.

IntelliSenseIntelliSense

现在默认使用全新的基于 SQLite 的数据库引擎。The new SQLite-based database engine is now being used by default. 这将提高数据库操作(如“转到定义”和“查找所有引用”)的速度,并将极大地缩短初始解决方案分析时间。This will speed up database operations like Go To Definition and Find All References, and will significantly improve initial solution parse time. 设置已移至“工具 | 选项 | 文本编辑器 | C/C++ | 高级”(之前位于“...C/C++ | 实验”下)。The setting has been moved to Tools | Options | Text Editor | C/C++ | Advanced (it was formerly under ...C/C++ | Experimental).

  • 我们改进了不使用预编译标头的项目和文件的 IntelliSense 性能 - 为当前文件中的标头创建自动预编译标头。We've improved IntelliSense performance on projects and files not using precompiled headers - an Automatic Precompiled Header will be created for headers in the current file.

  • 还为错误列表中的 IntelliSense 错误添加了错误筛选和帮助。We've added error filtering and help for IntelliSense errors in the error list. 单击错误列现在允许进行筛选。Clicking on the error column now allows for filtering. 此外,单击特定错误或按 F1 将启动错误消息的联机搜索。Also, clicking on the specific errors or pressing F1 will launch an online search for the error message.

    错误列表Error List

    筛选的错误列表Error List Filtered

  • 增添了按类型筛选“成员列表”项的功能。Added the ability to filter Member List items by kind.

    成员列表筛选Member List Filtering

  • 添了新的实验性预测 IntelliSense 功能,此功能可根据上下文筛选成员列表中的所示内容。Added a new experimental Predictive IntelliSense feature that provides contextually-aware filtering of what appears in the Member List. 请参阅 C++ IntelliSense Improvements – Predictive IntelliSense & Filtering(C++ IntelliSense 改进 - 预测 IntelliSense 和筛选)See C++ IntelliSense Improvements - Predictive IntelliSense & Filtering

  • 即使在复杂基本代码中,“查找所有引用”(Shift+F12) 现在也可帮助轻松进行查找。Find All References (Shift+F12) now helps you get around easily, even in complex codebases. 它提供高级分组、筛选、排序、在结果中搜索以及(适用于某些语言的)着色,以便你清楚了解自己的引用。It provides advanced grouping, filtering, sorting, searching within results, and (for some languages) colorization, so you can get a clear understanding of your references. 对于 C++ 而言,新的UI 包括有关是否要从变量读取或向其写入的信息。For C++, the new UI includes information about whether we are reading from or writing to a variable.

  • 已将“点到箭头”IntelliSense 功能从实验级提升为高级,且现在为默认启用。The Dot-to-Arrow IntelliSense feature has been moved from experimental to advanced, and is now enabled by default. 编辑器功能“展开作用域”和“展开优先级”也已从实验级提升为高级。The editor features Expand Scopes and Expand Precedence have also been moved from experimental to advanced.

  • 实验性的重构功能“更改签名”和“提取函数”现默认可用。The experimental refactoring features Change Signature and Extract Function are now available by default.

  • 用于 C++ 项目的实验性功能“快速项目加载”。The experimental feature for C++ projects 'Faster project load'. 下次打开 C++ 项目时,加载速度将更快,并且越来越快!The next time you open a C++ project it will load faster, and the time after that it will load really fast!

其中一些功能与其他语言通用,有些则特定于 C++。Some of these features are common to other languages, and some are specific to C++. 有关这些新增功能的详细信息,请参阅发布 Visual Studio “15”For more information about these new features, see Announcing Visual Studio “15”.

包含“打开文件夹”的非 MSBuild 项目Non-MSBuild projects with Open Folder

Visual Studio 2017 引入了“打开文件夹”功能,使得能够在包含源代码的文件夹中进行编码、生成和调试,而无需创建任何解决方案或项目。Visual Studio 2017 introduces the “Open Folder” feature, which enables you to code, build and debug in a folder containing source code without the need to create any solutions or projects. 这使得使用 Visual Studio 变得更简单,即使你的项目不基于 MSBuild。This makes it much simpler to get started with Visual Studio even if your project is not an MSBuild-based project. 使用“打开文件夹”,可获得 Visual Studio 为 MSBuild 所提供的强大代码理解、编辑、生成和调试功能。With “Open Folder” you get access to the powerful code understanding, editing, building and debugging capabilities that Visual Studio already provides for MSBuild projects. 有关详细信息,请参阅 Visual C++ 中的“打开文件夹”项目For more information, see Open Folder projects in Visual C++.

  • 改进了“打开文件夹”体验。Improvements to the Open Folder experience. 可通过以下 json 文件自定义体验:You can customize the experience through these json files:
    • 使用 CppProperties.json 可自定义 IntelliSense 和浏览体验。CppProperties.json to customize the IntelliSense and browsing experience.
    • 使用 Tasks.json 可自定义生成步骤。Tasks.json to customize the build steps.
    • 使用 Launch.json 可自定义调试体验。Launch.json to customize the debugging experience.

Visual Studio 2017 版本15.3Visual Studio 2017 version 15.3:

  • 改进了对备用编译器和生成环境(如 MinGW 和 Cygwin)的支持。Improved support for alternative compilers and build environments such as MinGW and Cygwin. 有关详细信息,请参阅将 MinGW 和 Cygwin 与 Visual C++ 和“打开文件夹”结合使用For more information, see Using MinGW and Cygwin with Visual C++ and Open Folder.
  • 添加了支持,以定义“CppProperties.json”和“CMakeSettings.json”中的全局和特定于配置的环境变量。Added support to define global and configuration specific environment variables in "CppProperties.json" and "CMakeSettings.json". “launch.vs.json”中定义的调试配置和“tasks.vs.json”中的任务可以使用这些环境变量。These environment variables can be consumed by debug configurations defined in "launch.vs.json" and tasks in "tasks.vs.json". 有关详细信息,请参阅Customizing your Environment with Visual C++ and Open Folder(使用 Visual C++ 和“打开文件夹”自定义环境)。For more information, see Customizing your Environment with Visual C++ and Open Folder.
  • 改进了对 CMake 的 Ninja 生成器的支持,包括轻松定位 64 位平台的能力。Improved support for CMake's Ninja generator, including the ability to easily target 64-bit platforms.

通过“打开文件夹”支持 CMakeCMake support via Open Folder

Visual Studio 2017 支持在不转换为 MSBuild 项目文件 (.vcxproj) 的情况下使用 CMake 项目。Visual Studio 2017 introduces support for using CMake projects without converting to MSBuild project files (.vcxproj). 有关详细信息,请参阅 Visual C++ 中的 CMake 项目For more information, see CMake projects in Visual C++. 使用“打开文件夹”打开 CMake 项目时会自动配置用于 C++ 编辑、构建和调试的环境。Opening CMake projects with “Open Folder” will automatically configure the environment for C++ editing, building and debugging.

  • 无需在根文件夹中创建 CppProperties.json 文件,C++ IntelliSense 便可正常工作。C++ IntelliSense will work without the need to create a CppProperties.json file in the root folder. 此外,我们增添了一个新的下拉列表,允许用户在分别由 CMake 和 CppProperties.json 文件提供的配置之间轻松切换。Along with this, we've added a new dropdown to allow users to easily switch between configurations provided by CMake and CppProperties.json files.

  • 通过 CMakeLists.txt 文件所在的同一文件夹中的 CMakeSettings.json 文件提供进一步的配置支持。Further configuration is supported via a CMakeSettings.json file that sits in the same folder as the CMakeLists.txt file.

    Cmake 打开文件夹Cmake Open Folder

Visual Studio 2017 版本 15.3:添加了对 CMake Ninja 生成器的支持。Visual Studio 2017 version 15.3: Support added for the CMake Ninja generator. 有关详细信息,请参阅 Visual C++ 中的 CMake 项目For more information, see CMake projects in Visual C++.

Visual Studio 2017 版本 15.5:添加了对导入现有 CMake 缓存的支持。Visual Studio 2017 version 15.5: Support added for importing existing CMake caches. 有关详细信息,请参阅 Visual C++ 中的 CMake 项目For more information, see CMake projects in Visual C++.

使用 C++ 的 Windows 桌面开发Windows desktop development with C++

现提供原始 C++ 工作流的更细化的安装体验。We now provide a more granular installation experience for installing the original C++ workload. 我们添加了可选组件,使你能够仅安装所需工具。We have added selectable components that enable you to install just the tools that you need. 请注意,在安装程序用户界面中列出的组件的安装大小的指示并不准确,而且它低估了整个大小。Please note that the indicated installation sizes for the components listed in the installer UI are not accurate and underestimate the total size.

若要在 C++ 桌面工作负载中成功创建 Win32 项目,则必须安装工具集和 Windows SDK。To successfully create Win32 projects in the C++ desktop workload, you must install both a toolset and a Windows SDK. 安装推荐(选中)的组件“VC++ 2017 v141 工具集(x86、x64)”和“Windows 10 SDK (10.0.14393)”可以确保正常运行。Installing the recommended (selected) components “VC++ 2017 v141 toolset (x86, x64)” and “Windows 10 SDK (10.0.14393)” will ensure this will work. 如果未安装所需工具,将无法成功创建项目,且向导将挂起。If the necessary tools are not installed, projects will not be created successfully and the wizard will hang.

Visual Studio 2017 版本 15.5:Visual C++ 生成工具(以前作为单独的产品提供)现在作为工作负荷包括在 Visual Studio 安装程序中。Visual Studio 2017 version 15.5: The Visual C++ Build tools (previously available as a standalone product) are now included as a workload in the Visual Studio Installer. 此工作负荷仅安装生成 C++ 项目所需的工具,而不安装 Visual Studio IDE。This workload installs only the tools required to build C++ projects without installing the Visual Studio IDE. 包括 v140 和 v141 工具集。Both the v140 and v141 toolsets are included. v141 工具集包含 Visual Studio 2015 版本 15.5 中的最近改进。The v141 toolset contains the lastest improvements in Visual Studio 2015 version 15.5. 有关详细信息,请参阅 Visual Studio Build Tools now include the VS2017 and VS2015 MSVC Toolsets(Visual Studio 生成工具现在包含 VS2017 和 VS2015 MSVC 工具集)。For more information, see Visual Studio Build Tools now include the VS2017 and VS2015 MSVC Toolsets.

使用 C++ 的 Linux 开发Linux development with C++

热门扩展“用于 Linux 开发的 Visual C++”现已纳入 Visual Studio。The popular extension Visual C++ for Linux Development is now part of Visual Studio. 此安装提供开发和调试运行在 Linux 环境中的 C++ 应用程序所需的一切信息。This installation provides everything you need to develop and debug C++ applications running on a Linux environment.

Visual Studio 2017 版本 15.2:跨平台代码共享和类型可视化的改进。Visual Studio 2017 version 15.2: Improvements for cross-platform code sharing and type visualization. 有关详细信息,请参阅跨平台代码共享和类型可视化的 Linux C++ 改进For more information, see Linux C++ improvements for cross-platform code sharing and type visualization.

Visual Studio 2017 版本 15.5Visual Studio 2017 version 15.5:

  1. Linux 工作负荷添加了对 rsync 作为 sftp 的替代方法将文件同步到远程 Linux 计算机的支持。The Linux workload has added support for rsync as an alternative to sftp for synchronizing files to remote Linux machines.
  2. 添加了对针对 ARM 微控制器的交叉编译的支持。Support is added for cross compilation targeting ARM microcontrollers. 要在安装中启用此支持,请选择使用 C++ 工作负荷的 Linux 开发,并选择“嵌入和 IoT 开发”选项。To enable this in the installation choose the Linux development with C++ workload and select the option for Embedded and IoT Development. 此操作将 ARM GCC 交叉编译工具和 Make 添加到你的安装。This adds the ARM GCC cross compilation tools and Make to your installation. 有关详细信息,请参阅 ARM GCC Cross Compilation in Visual Studio(Visual Studio 中的 ARM GCC 交叉编译)。For more information, see ARM GCC Cross Compilation in Visual Studio.
  3. 添加了对 CMake 的支持。Support added for CMake. 现在即可处理现有的 CMake 基本代码,无需将其转换为 Visual Studio 项目。You can now work on your existing CMake code base without having to convert it to a Visual Studio project. 有关详细信息,请参阅配置 Linux CMake 项目For more information, see Configure a Linux CMake Project.
  4. 添加了对运行远程任务的支持。Support added for running remote tasks. 此功能允许在 Visual Studio 连接管理器定义的远程系统上运行任意命令。This capability allows you to run any command on a remote system that is defined in Visual Studio’s Connection Manager. 远程任务还提供将文件复制到远程系统的功能。Remote tasks also provide the capability to copy files to the remote system.

使用 C++ 的游戏开发Game development with C++

以 DirectX 或 Cocos2d 为后盾,利用 C++ 的强大功能构建专业游戏。Use the full power of C++ to build professional games powered by DirectX or Cocos2d.

使用 C++ 的移动开发(Android 和 iOS)Mobile development with C++ (Android and iOS)

现可利用 Visual Studio 创建和调试面向 Android 和 iOS 的移动应用。You can now create and debug mobile apps using Visual Studio that can target Android and iOS.

通用 Windows 应用Universal Windows Apps

C++ 是通用 Windows 应用工作负荷的可选组件。C++ comes as an optional component for the Universal Windows App workload. 当前必须手动完成 C++ 项目的升级。Upgrading C++ projects currently must be done manually. 如果在 Visual Studio 2017 中打开面向 v140 的 UWP 项目,且如果没有安装 Visual Studio 2015,则需要在项目属性页中选择 v141 平台工具集。If you open a v140-targeted UWP project in Visual Studio 2017, you need to select the v141 platform toolset in the project property pages if you do not have Visual Studio 2015 installed.

通用 Windows 平台 (UWP) 上 C++ 的新选项New options for C++ on Universal Windows Platform (UWP)

现在,你拥有了为通用 Windows 平台和 Windows 应用商店编写和打包 C++ 应用程序的新选项:可使用 Desktop App Converter 打包现有的桌面应用程序,用于通过 Windows 应用商店部署。You now have new options for writing and packaging C++ applications for the Universal Windows Platform and the Windows Store: You can use the Desktop App Converter to package your existing desktop application for deployment through the Windows Store. 有关详细信息,请参阅 Using Visual C++ Runtime in Centennial project(在 Centennial 项目中使用 Visual C++ 运行时)和 Bring your desktop app to the Universal Windows Platform (UWP) with the Desktop Bridge(使用桌面桥将桌面应用引入通用 Windows 平台 (UWP))。For more information, see Using Visual C++ Runtime in Centennial project and Bring your desktop app to the Universal Windows Platform (UWP) with the Desktop Bridge.

Visual Studio 2017 版本 15.5Visual Studio 2017 version 15.5
添加了“Windows 应用程序打包项目”项目模板,支持使用桌面桥打包桌面应用程序。A Windows Application Packaging Project project template is added which supports packaging desktop applications by using Desktop Bridge. 可在“文件| 新建 | 项目 | 已安装 | Visual C++ | 通用 Windows 平台”下获得此模板。It is available under File | New | Project | Installed | Visual C++ | Universal Windows Platform.

在编写新代码时可使用 C ++ / WinRT,它是 Windows 运行时的标准 C ++ 语言投影,仅在头文件中实现。When writing new code, you can now use C++/WinRT, a standard C++ language projection for the Windows Runtime implemented solely in header files. 它使你可以使用任何符合兼容的 C++ 编译器创作和使用 Windows 运行时 API。It allows you to both author and consume Windows Runtime APIs using any standards-compliant C++ compiler. C++/WinRT 旨在为 C++ 开发人员提供对新式 Windows API 的优先访问权限。C++/WinRT is designed to provide C++ developers with first-class access to the modern Windows API. 有关详细信息,请参阅 GitHub 上提供的 C++/WinRFor more information, see C++/WinRT Available on GitHub.

Windows SDK Insider Preview 的 内部版本 17025 起,C++/WinRT 包含在 Windows SDK 中。As of build 17025 of the Windows SDK Insider Preview, C++/WinRT is included in the Windows SDK. 有关详细信息,请参阅 C++/WinRT is now included the Windows SDK(C++/WinRT 现在包含在 Windows SDK 中)。For more information, see C++/WinRT is now included the Windows SDK.

Clang/C2 平台工具集Clang/C2 platform toolset

Visual Studio 2017Visual Studio 2017 附带的 Clang/C2 工具集现在支持 /bigobj 开关,这对生成大项目来说至关重要。The Clang/C2 toolset that ships with Visual Studio 2017Visual Studio 2017 now supports the /bigobj switch, which is crucial for building large projects. 它还在编译器的前端和后端进行了多项重要的 bug 修复。It also includes several important bug fixes, both in the front-end and the back-end of the compiler.

C++ 代码分析C++ code analysis

用于强制执行 C++ 核心准则 的 C++ 核心检查器现已通过 Visual Studio 分发。The C++ Core Checkers for enforcing the C++ Core Guidelines are now distributed with Visual Studio. 只需在项目“属性”页的“代码分析扩展”对话框中启动检查器,即会在运行代码分析时包含扩展。Simply enable the checkers in the Code Analysis Extensions dialog in the project's property pages and the extensions will be included when you run code analysis. 有关详细信息,请参阅使用 C++ 核心准则检查器For more information, see Using the C++ Core Guidelines checkers.

CppCoreCheckCppCoreCheck

Visual Studio 2017 版本 15.3:添加了对与资源管理相关的规则的支持。Visual Studio 2017 version 15.3: Support added for rules related to resource management.

Visual Studio 2017 版本 15.5:新的 C++ Core Guidelines 检查包含智能指针正确性、全局初始化表达式的正确使用和标记构造(如 goto 和错误转换)的使用。Visual Studio 2017 version 15.5: New C++ Core Guidelines checks cover smart pointer correctness, correct use of global initializers, and flagging uses of constructs like goto and bad casts.
15.3 中可能存在的一些警告编号在 15.5 中不再可用。Some warning numbers you may find in 15.3 are no longer available in 15.5. 这些警告被更具体的检查替换。These warnings were replaced with more specific checks.

单元测试Unit testing

Visual Studio 2017 版本 15.5:Google Test Adapter 和 Boost.Test Adapter 现在作为“使用 C++ 的桌面开发”的组件提供,并与“测试资源管理器”集成。Visual Studio 2017 version 15.5: Google Test Adapter and Boost.Test Adapter are now available as components of the Desktop Development with C++ and are integrated with Test Explorer. 添加了对 Cmake 项目(使用“打开文件夹”)的 CTest 支持,虽然与“测试资源管理器”的完全集成尚不可用。CTest support is added for Cmake projects (using Open Folder) although full integration with Test Explorer is not yet available. 有关详细信息,请参阅编写 C/C++ 单元测试For more information, see Writing unit tests for C/C++.

Visual Studio 图形诊断Visual Studio graphics diagnostics

Visual Studio 图形诊断是一套工具,用于记录、分析 Direct3D 应用中的渲染和性能问题。Visual Studio Graphics Diagnostics is a set of tools for recording and analyzing rendering and performance problems in Direct3D apps. 可对在 Windows 电脑上、在 Windows 设备模拟器中或在远程电脑或设备上本地运行的应用使用图形诊断功能。Graphics Diagnostics features can be used with apps that are running locally on your Windows PC, in a Windows device emulator, or on a remote PC or device.

  • 顶点和几何着色的输入和输出:查看顶点着色和几何着色的输入和输出一直以来是最渴求的功能之一,工具中现已支持此功能。Input & Output for Vertex and Geometry shaders: The ability to view input and output of vertex shaders and geometry shaders has been one of the most requested features, and it is now supported in the tools. 只需在“管道阶段”视图中选择“VS”或“GS”阶段,即可在下面的表中开始检查其输入和输出。Simply select the VS or GS stage in the Pipeline Stages view to start inspecting its input and output in the table below.

    着色器的输入/输出

  • 在对象表中搜索和筛选:提供一种快捷简单的方法来查找所需资源。Search and filter in the object table: Provides a quick and easy way to find the resources you're looking for.

    搜索

  • 资源历史记录:这种新视图提供了一种简化的方式,以在渲染捕获的帧期间使用资源时查看该资源的整个修改历史记录。Resource History: This new view provides a streamlined way of seeing the entire modification history of a resource as it was used during the rendering of a captured frame. 若要调用任何资源的历史记录,只需单击任意资源超链接旁边的时钟图标。To invoke the history for any resource, simply click the clock icon next to any resource hyperlink.

    资源历史记录

    这将显示新的资源历史记录工具窗口,它由资源的更改历史记录所填充。This will display the new Resource History tool window, populated with the change history of the resource.

    资源历史记录更改

    请注意,如果在捕获帧时启用了完整调用堆栈捕获(“Visual Studio | 工具 | 选项 | 图形诊断”),则可在 Visual Studio 项目中对每个更改事件的上下文进行快速推导和检查。Note that if your frame was captured with full call stack capturing enabled (Visual Studio | Tools | Options | Graphics Diagnostics), then the context of each change event can be quickly deduced and inspected within your Visual Studio project.

  • API 统计信息:在帧中查看 API 使用情况的高级摘要。API Statistics: View a high-level summary of API usage in your frame. 这样可以轻松发现那些你未意识到正在调用的,或调用太多次的调用。This can be handy in discovering calls you may not realize you’re making at all or calls you are making too much. 可在 Visual Studio 图形分析器中通过“视图 | API 统计信息”使用此窗口。This window is available via View | API Statistics in Visual Studio Graphics Analyzer.

    API 统计信息

  • 内存统计信息:查看驱动程序为你在帧中所创建的资源分配了多少内存。Memory Statistics: View how much memory the driver is allocating for the resources you create in the frame. 可在“Visual Studio 图形分析器”中通过“视图 | 内存统计信息”使用此窗口。This window is available via View | Memory Statistics in Visual Studio Graphics Analyzer. 通过右键单击并选择“全部复制”,可将数据复制到 CSV 文件,以便在电子表格中查看。Data can be copied to a CSV file for viewing in a spreadsheet by right clicking and choosing Copy All.

    内存统计信息

  • 框架验证:新的错误和警告列表提供了一种简单的方式,以导航到基于潜在问题(由 Direct3D 调试层检测)的事件列表。Frame Validation: The new errors and warnings list provides an easy way to navigate your event list based on potential issues detected by the Direct3D debug layer. 在 Visual Studio 图形分析器中单击“视图 | 帧验证”,可打开该窗口。Click View | Frame Validation in Visual Studio Graphics Analyzer to open the window. 然后单击“运行验证”,开始分析。Then click Run Validation to start the analysis. 这可能耗费数分钟时间,具体取决于帧的复杂性。It can take several minutes to complete, depending on the frame's complexity.

    帧验证

  • 对 D3D12 的帧分析:使用帧分析来分析具有定向“假设”试验的绘图调用性能。Frame Analysis for D3D12: Use Frame Analysis to analyze draw call performance with directed “what-if” experiments. 切换至“帧分析”选项卡,然后运行分析以查看报告。Switch to the Frame Analysis tab and run analysis to view the report. 有关详细信息,请观看 GoingNative 25: Visual Studio Graphics Frame Analysis(GoingNative 25:Visual Studio 图形帧分析)视频。For more details, watch the GoingNative 25: Visual Studio Graphics Frame Analysis video.

    帧分析

  • GPU 使用情况改进:使用 GPU 视图或 Windows Performance Analyzer (WPA) 工具,打开通过 Visual Studio GPU 使用情况探查器获取的跟踪,以便获取更详细的分析。GPU Usage Improvements: Open traces taken via the Visual Studio GPU Usage profiler with either GPU View or the Windows Performance Analyzer (WPA) tool for more detailed analysis. 如果安装了 Windows Performance Toolkit,则在会话概述的右下方将有两个超链接,一个指向 WPA,另一个指向 GPU 视图。If you have the Windows Performance Toolkit installed there will be two hyperlinks, one for WPA and other for GPU View, at the bottom right of the session overview.

    GPU 使用情况

    通过此链接在 GPU 视图中打开的跟踪支持在 VS 和 GPU 视图之间的时间线中进行同步缩放和平移。Traces opened in GPU View via this link support synchronized zooming and panning in the timeline between VS and GPU View. VS 中的复选框用于控制是否启用同步。A checkbox in VS is used to control whether synchronization is enabled or not.

    GPU 视图