August 13th, 2024

What’s New for C++ Developers in Visual Studio 2022 17.11

Sy Brand
C++ Developer Advocate

We are happy to announce that Visual Studio 2022 version 17.11 is now generally available! This post summarizes the new features you can find in this release for C++. You can download Visual Studio 2022 from the Visual Studio downloads page or upgrade your existing installation by following the Update Visual Studio Learn page.

Standard Library

We’re continuing to improve our open source standard library implementation. Thank you to everyone who has contributed features and fixes to this release! You can find the full set of changes at the STL changelog.

Formatted Output

We’ve made several advancements in our formatted output implementation. As part of P2286R8 Formatting Ranges, we’ve implemented std::range_formatter and formatters for std::pair and std::tuple. We’ve also added support for calling std::println() with no arguments, which prints a blank line (proposed in P3142R0, which importantly also includes a recipe for banana bread).

Diagnostics

This release also comes with some improved error messages for a couple of scenarios. The first is for when you call std::get<T> on a std::tuple that has multiple instances of T in its template arguments. MSVC used to produce the following error:

error C2338: static_assert failed: 'duplicate type T in get<T>(tuple)'

In Visual Studio 17.11, MSVC produces this error:

error C2338: static_assert failed: 'get<T>(tuple<Types...>&) requires T to occur exactly once in Types. (N4971 [tuple.elem]/5)'

We also improved the diagnostics for when std::ranges::to is unable to construct the requested result. MSVC used to print a message such as this:

error C2338: static_assert failed: 'the program is ill-formed per N4950 [range.utility.conv.to]/2.3'

In Visual Studio 2022 17.11, we provide more details:

error C2338: static_assert failed: 'ranges::to requires the result to be constructible from the source range, either by using a suitable constructor, or by inserting each element of the range into the default-constructed object. (N4981 [range.utility.conv.to]/2.1.5)'

Vectorization

We’ve improved vectorization for several algorithms, some by adding custom vectorized implementations, some by helping the compiler auto-vectorize the code. The improved algorithms are:

  • replace_copy()replace_copy_if()ranges::replace_copy, and ranges::replace_copy_if
  • find_first_of() and ranges::find_first_of for 8-bit and 16-bit elements
  • mismatch() and ranges::mismatch
  • count() and ranges::count
  • find(), ranges::find, and ranges::find_last
  • ranges::iota

Core Editor

Code Search Scoping

You can now narrow the scope of code searches with the newly added scoping options.

For the default code search experience and each filter, you can now set the scope to Entire solutionCurrent project, or Current document and toggle inclusion of external files.

You can set different scopes for different filters. For example, the default experience can be set to look through Entire solution and members can be set to look through only current document. Your selections will be preserved past the current session.

A screenshot of a computer Description automatically generated

This feature must be enabled under Tools -> Manage Preview Features.

Pull Request Support in Visual Studio

Pull Request Comments

We’ve made it easier to view your GitHub and Azure DevOps pull request comments directly in your working file in Visual Studio. You can now stay in your context, make necessary code changes, and interact with your colleagues’ suggestions without switching contexts to the browser.

Enable the feature flag, Pull Request Comments, checkout any branch with an active pull request branch, and click on Show comments in files in the InfoBar.

View pull request comments notification

The latest improvements include better support for @ mentions and work item references, visual improvements to the attention dot and comment margin, the addition of avatars, better sync with the server, and an additional entry point in the Git changes window. This feature must be enabled under Tools -> Manage Preview Features.

Pull Requests Using Drafts and Templates

You can now create pull request drafts and start your descriptions with GitHub templates in Visual Studio. These were the two top requests for the create a pull request experience.

Use the drop-down menu on the Create button to Create as Draft.

Create pull requests draft option

Your default PR template will be used when creating a new PR for both GitHub and Azure DevOps. Learn more about how to add a PR template to your repository in the GitHub documentation and Azure DevOps documentation. This feature must be enabled under Tools -> Manage Preview Features.

Game Development

Build Insights Quality of Life Update

In this update, we added quality of life changes to C++ Build Insights integration. You can now filter your Build Insights trace results by project. For results in each row, you will now see the relative path and file name instead of the full path. We have also improved the grouping of results in the Included Files view.

Build Insights QoL Update

Unreal Engine Add Class Templates

You can now add additional common Unreal Engine class templates to your project with the new Add Class dialog. This dialog provides a list of common Unreal Engine class templates that you can add to your project. You can also now add your class to a module of your choosing.

To get started, right click on the project in Solution Explorer and select Add > Unreal Engine Item. In the Add New Item dialog, select Unreal Engine Class to open the Add Class dialog.

Unreal Engine Add Class

Unreal Engine Add Module

You can now add Unreal Engine modules to your project with the new Add Module dialog.

To get started, right click on the project in Solution Explorer and select Add > Unreal Engine Item. In the Add New Item dialog, select Empty Unreal Engine Module to open the Add Module dialog.

Unreal Engine Add Class

Unreal Engine Toolbar

The new Unreal Engine toolbar provides quick access to Unreal Engine related actions. The toolbar is available when you have an Unreal Engine project loaded in Visual Studio. The toolbar includes the following actions:

  1. Quickly attach to Unreal Engine processes
  2. Rescan Blueprints Cache
  3. Quick Access to Unreal Engine Log
  4. Quick Access Unreal Engine Configuration Page for Visual Studio

Unreal Engine Toolbar

Cross-Platform

CMake Debugger Linux Support

We have added support for the CMake debugger in CMake projects targeting Linux via WSL or SSH. The CMake debugger allows you to debug your CMake scripts and CMakeLists.txt files through the Visual Studio debugger.

To start a CMake debugging session, set a breakpoint in your CMakeLists.txt file and then navigate to Project > Configure Cache with CMake Debugging.

CMake debugger Linux

Debugging

Faster C++ Breakpoints

We have significantly enhanced the performance of conditional breakpoints in C++ through a reworked implementation.

Beginning with version 17.11, our initial assessment finds that execution time is almost four times as fast, reducing execution time from 80 seconds to 21 seconds over 80,000 iterations.

Auto-add Breakpoints to the Default Group

You can now mark the selected breakpoint group as the default, ensuring all newly added breakpoints are automatically included in that group.

Default Breakpoint Group

GitHub Copilot

Copilot Naming Suggestions

GitHub Copilot can now generate naming suggestions for your identifiers (variables, methods, or classes) based on how your identifier is being used and the style of your code.

Rename suggestions

To try it out, you’ll need an active GitHub Copilot subscription. Navigate to any variable you wish to rename, right-click -> Rename (Keyboard: Ctrl+R, Ctrl+R). You’ll notice a GitHub Copilot sparkle icon that you can click or toggle to generate naming suggestions.

Copilot in Quick Info

When you hover over symbols in your codebase, you’ll now have the ability to invoke Copilot conveniently within the Quick Info dialog to learn more about a given symbol and enhance existing or lacking code documentation.

Send us your feedback

We are very much interested in your feedback to continue to improve this experience. The comments below are open. Feedback can also be shared through Visual Studio Developer Community. You can also reach us on Twitter (@VisualC), or via email at visualcpp@microsoft.com.

 

Author

Sy Brand
C++ Developer Advocate

Sy Brand is Microsoft’s C++ Developer Advocate. Their background is in compilers and debuggers for embedded accelerators, but they’re also interested in generic library design, metaprogramming, functional-style C++, undefined behaviour, and making our communities more inclusive and welcoming.

1 comment

Discussion is closed. Login to edit/delete existing comments.

  • Tom Kirby-Green

    Loving all these native code investments! Kudos.