What's new for C++ in Visual Studio 2022

Visual Studio 2022 brings many updates and fixes to the Microsoft C++ compiler and tools. The Visual Studio IDE also offers significant improvements in performance and productivity, and now runs natively as a 64-bit application.

What's new for C++ in Visual Studio version 17.9

Briefly, some of the new features are:

  • #include diagnostics, which provides a detailed analysis of your #include directives. Activate this feature by right-clicking an #include and choosing #include directives > Turn #include directive diagnostics on. Above each #include is the number of times your code references that #include file. Click the reference link to navigate to where your code uses something from that header file. To view the build time of your #include directives, run Build Insights by navigating to Build > Run Build Insights on Solution > Build.

    Screenshot of #include diagnostics

    Above the # include is a **reference** link and a number of the references to this # include file (in this case 1). The build time is also listed (in this case less than 1/2 a second).

  • Memory layout visualization, which shows how memory is arranged for your classes, structs, and unions. Hover over a type and choose the Memory Layout link in the Quick Info to open a dedicated window displaying the memory layout of the selected type. Hovering over individual data types within this window provides detailed information about their size and offset within the type.

    Screenshot of the memory layout window

    The memory layout window shows the contents of the Snake class. It shows the memory offsets of the various fields of the class such as Point classes for the location of the head and body, the score, and so on.

  • You can now specify your own custom CMake executable. This feature is useful if you want to use a specific version of CMake that isn't shipped with Visual Studio. Navigate to Tools > Options and select CMake > General. Select Enable custom CMake executable and specify the directory path of your CMake executable.

    Screenshot of the CMake options dialog

    The CMake options dialog with the "Enable custom CMake executable" option and "CMake Executable Directory" field highlighted.

  • Improved IntelliSense for Unreal Engine projects.
  • Improved C++23 support: std::format and std::span formattable, range_format, format_kind, and set_debug_format() as part of P2286R8 Formatting Ranges <mdspan> per P0009R18 and subsequent wording changes that were applied to the C++23 Standard. Also, format() can format pointers per P2510R3.

For a summary of C++ backend updates, see MSVC Backend updates since Visual Studio 2022 version 17.3.

For a summary of new features in the Visual Studio 17.9 IDE, see Visual Studio 2022 version 17.9 Release Notes.

What's new for C++ in Visual Studio version 17.8

Briefly, some of the new features are:

  • C++ structured diagnostics in the Output window and a new problem details window that provides more information about the error. For more information, see Structured SARIF Output and Problem Details Window.
  • A feature that lets you visualize the size and alignment of your classes, structs, unions, base types, or enums even before the code is compiled. Hover over the identifier and a Quick Info displays the size and alignment information.
  • A feature that suggests when to mark member functions const because they don’t modify the object’s state. Hover over a member function and click the light bulb icon to mark the function as const.
  • Visual Studio now prompts you to mark global functions as static via a screwdriver icon that appears by the function name. Click the screwdriver icon to mark the function as static.
  • Unused #include directives are dimmed in the editor. You can hover over a dimmed include and use the light bulb menu to either remove that include or all unused includes. You can also add #include directives for entities that are indirectly included via other headers. For more information, see Clean up C/C++ includes in Visual Studio.
  • More Unreal Engine support:
    • Unreal Engine Test Adapter lets you discover, run, manage, and debug your Unreal Engine tests without leaving the Visual Studio IDE.
    • With Unreal Engine Code Snippets, you can find common Unreal Engine constructs as snippets in your member list.
    • Build Insights is now integrated with Visual Studio 2022 and works with MSBuild and CMake projects using MSVC. You can now see additional information about the compilation of a function such as how long it took to compile and the number of ForceInlines.
  • Remote Linux unit test support now lets you run your CTest and GTest tests on your remote Linux machines from Visual Studio’s Test Explorer, just like your local tests.

For a comprehensive summary of new C++ features in Visual Studio 17.8, see What’s New for C++ Developers in Visual Studio 2022 17.8.

For a summary of new features in the Visual Studio 17.8 IDE, see Visual Studio 2022 version 17.8 Release Notes.

What's new for C++ in Visual Studio version 17.7

For a summary of new C++ features in Visual Studio 17.7, see What’s New for C++ Developers in Visual Studio 2022 17.7.

Briefly, some of the new features are:

  • Faster debugging sessions and faster project load times
  • Step-by-step visualization of macro expansion
  • One-click download for Windows Subsystem for Linux (WSL)
  • Improved support for Doxygen comments
  • C++ Build Insights for game development
  • Added /std:clatest for the C compiler.
  • Unreal Engine project improvements such as faster IntelliSense and syntax colorization, the ability to find all Unreal Engine Blueprint references, and more.

For a summary of new C++ features that are specific to game development, see Unleashing the Power of Visual Studio 2022 for C++ Game Development

For a summary of new features in the Visual Studio 17.7 IDE, see Visual Studio 2022 version 17.7 Release Notes.

What's new for C++ in Visual Studio version 17.6

For a summary of new C++ features in Visual Studio 17.6, see What’s New for C++ Developers in Visual Studio 2022 17.6.

Briefly, some of the new features are: CMake script debugging, built-in support for High Level Shading Language (HLSL), an Unreal Engine Log viewer, initial support for C++20 in C++/CLI projects, VCPKG is now added by default, and some C++23 standard library features for ranges. To see a full list of new features added to the standard library, see the STL changelog.

For a summary of new features in Visual Studio 17.6 IDE, see Visual Studio 2022 version 17.6 Release Notes.

What's new for C++ in Visual Studio version 17.5

For a summary of new C++ features in Visual Studio in version 17.5, see What’s New for C++ Developers in Visual Studio 2022 17.5. For a summary of new features and bug fixes in the Visual Studio IDE version 17.5, see Visual Studio 2022 version 17.5 Release Notes.

  • std::move, std::forward, std::move_if_noexcept, and std::forward_like now don't produce function calls in generated code, even in debug mode. This change avoids named casts causing unnecessary overhead in debug builds. /permissive- (or an option that implies it, such as /std:c++20 or std:c++latest) is required.

  • Added [[msvc::intrinsic]] to support the above item. You can apply this attribute to nonrecursive functions consisting of a single cast, which take only one parameter.

  • Added support for Linux Console in the Integrated Terminal, which allows for terminal I/O.

  • Added initial experimental support for C11 atomic primitives (<stdatomic.h>). You can enable this experimental feature with the /experimental:c11atomics option in /std:c11 mode or later.

  • Added a new set of experimental high-confidence checks to the Lifetime Checker for reduced noise.

  • A new preview feature, Remote File Explorer, lets you view the file directory on your remote machines within VS, and upload and download files to it.

  • Changed versioning of CMake executables shipped with Visual Studio to match Kitware versions.

  • Added support for Hot Reload to the CMake Project template.

  • Go To Definition for C++ now uses a more subtle indicator of the operation taking more time, replacing the modal dialog from previous versions.

  • Started rollout of an experiment providing more smart results in the C++ autocompletion and member list. This functionality was previously known as Predictive IntelliSense but now uses a new presentation method.

  • We now ship a native Arm64 Clang toolset with our LLVM workload, allowing native compilation on Arm64 machines.

  • Added localization to the Image Watch Extension (This extension is available in the Marketplace, and isn't bundled through the Visual Studio Installer).

  • Added support for opening a Terminal window into the currently running Developer Container.

  • Made several improvements to IntelliSense macro expansion. Notably, we enabled recursive expansion in more contexts, and we added options to the pop up to copy the expansion to the clipboard or expand the macro inline.

  • Concurrent monitoring is now supported in the Serial Monitor. Concurrent monitoring allows you to monitor multiple ports at the same time side by side. Press the plus button to open another Serial Monitor and get started.

  • You can now view properties from base classes modified in an Unreal Blueprint asset without leaving Visual Studio. Double-click in a Blueprint reference for a C++ class or property to open the UE Asset Inspector in Visual Studio.

  • Enabled running DevContainers on a remote Linux machine.

  • Enabled selection of multiple targets to build in the CMake Targets view.

  • Added support for CMakePresets.json version 5. See the CMake documentation for information of new features.

  • Enabled Test Explorer to build and test multiple CMake targets in parallel.

  • Added "Open container in terminal" option to Dev Containers.

  • Implemented standard library features:

    • P2508R1 basic_format_string, format_string, wformat_string
    • P2322R6 ranges::fold_left, ranges::fold_right, and so on.
    • P2321R2 views::zip (doesn't include zip_transform, adjacent, and adjacent_transform)

What's new for C++ in Visual Studio version 17.4

For a summary of new features and bug fixes in Visual Studio in version 17.4, see Visual Studio 2022 version 17.4 Release Notes and What’s New for C++ Developers in Visual Studio 2022 17.4.

  • Improved compiler error messages to provide more correct and useful information, especially for concepts.

  • Added experimental MSVC option /experimental:log<directory> to output structured SARIF diagnostics to the specified directory.

  • Added support for C23 attributes to IntelliSense and continued progress in C++20 modules support.

  • Improved indexing performance when opening a new solution. Large projects could see a 20-35% improvement from 17.3.

  • Improved Named Return Value Optimization (NRVO):

    • NRVO is enabled for cases that involve exception handling or loops.
    • NRVO is enabled even under /Od if the user passes the /Zc:nrvo option, or /std:c++20 or later, or /permissive-.
    • You can now disable NRVO with the /Zc:nrvo- option.
  • Upgraded the version of LLVM shipped with Visual Studio to 15.0.1. For more information on what is available, see the LLVM and Clang release notes.

  • Added support to Visual Studio for vcpkg artifacts with CMake projects. For projects that include a vcpkg manifest, the environment is activated automatically on project open. Learn more about this feature in the vcpkg environment activation in Visual Studio blog post.

  • You can now use Dev Containers for your C++ projects. Learn more about this feature in our Dev Containers for C++ blog post.

  • IntelliSense now respects the order of preincluded headers when one of them is a PCH. Previously, when a PCH was used via /Yu and force-included via /FI, IntelliSense would always process it first, before any other headers included via /FI. This behavior didn't match the build behavior. With this change, /FI headers are processed in the order they're specified.

  • Removed internal prefixes from CTest names in Test Explorer.

  • Updated the version of CMake shipped with Visual Studio to version 3.24.1. For details of what is available, see the CMake release notes.

  • Android SDK update:

    • Ant scripts were removed, so users no longer see Ant-based templates in the New Project dialog. For help migrating from Ant templates to Gradle templates, see Migrating Builds From Apache Ant
    • Added support for building with NDK 23 and 24
    • Updated NDK component to the LTS version 23
  • Added vectorized implementations of ranges::min_element(), ranges::max_element(), and ranges::minmax_element()

  • We continue to track the latest developments in C++ standardization. Support for these C++23 features is available by including /std:c++latest in your compiler options:

    • P2302R4 ranges::contains, ranges::contains_subrange

    • P2499R0 string_view Range Constructor Should Be explicit

    • P0849R8 auto(x): decay-copy In The Language

      (The compiler part isn't implemented yet. The library part was implemented in C++20 mode when Ranges support was initially implemented.)

    • P0881R7 <stacktrace>

    • P2301R1 Add A pmr Alias For std::stacktrace

    • P1328R1 constexpr type_info::operator==()

    • P2440R1 ranges::iota, ranges::shift_left, ranges::shift_right

    • P2441R2 views::join_with

  • Added an option "Navigation after Create Declaration/Definition" to allow you to choose the navigation behavior of the Create Declaration/Definition feature. You can select between peeking (the default) or opening the document, or no navigation.

  • Arm64 builds of Visual Studio now bundle Arm64 versions of CMake and Ninja.

  • Added support for CMake Presets version 4. For details of what is available, see the CMake release notes.

  • Remote system connections using the Connection Manager now support SSH ProxyJump. ProxyJump is used to access an SSH host via another SSH host (for example, to access a host behind a firewall).

What's new for C++ in Visual Studio version 17.3

For a summary of new features and bug fixes in Visual Studio in version 17.3, see Visual Studio 2022 version 17.3 Release Notes and C++ improvements.

  • The Arm64EC toolchain is no longer marked as experimental and is ready for production use.

  • The Visual Studio Terminal can now be used as an SSH client with your stored SSH connections. With the C++ for Linux Tools installed, open the Terminal tool window. The Terminal dropdown is populated with your stored connections. When you select a connection, a new Terminal window opens inside Visual Studio that shows a pseudo-terminal on your remote system. Control characters, colors, and cursor positional awareness are all supported.

  • Visual Studio can now add Unreal Engine class templates for your UE projects. To try this feature, ensure IDE support for Unreal Engine is selected in the Game development with C++ workload in the Visual Studio Installer. When you're working on a UE project, right-click in the project or a folder/filter and select Add > UE Class.

  • Go to Definition now remembers the prior signature and navigates accordingly when a better match isn't available (for example, after you manually change the signature of one of the pair). The responsiveness of Go To All is improved. Previously, results appeared after you stopped typing. In the new experience, results show as you type.

  • In contexts requiring enum type completion (for example, assignments to enum variables, case labels, returning enum type, and so on), the autocompletion list is now filtered to just the matching enumerators and related constructs.

  • Added NuGet PackageReference support for C++/CLI MSBuild projects targeting .NET Core. This change was made to unblock mixed codebases from being able to adopt .NET Core. This support doesn't work for other C++ project types or any C++ project types targeting .NET Framework. There are no plans to extend PackageReference support to other C++ scenarios. The team is working on separate experiences involving vcpkg for non-MSBuild scenarios and to add greater functionality.

  • Added a Serial Monitor window for embedded development, available through Debug > Windows > Serial Monitor.

  • Improved C++ indexing by ~66% compared to 17.2.

  • Updated the version of CMake shipped with Visual Studio to version 3.23. See the CMake 3.23 release notes for details of what is available.

  • Upgraded the versions of LLVM tools shipped with Visual Studio to v14. For details of what is available, see the LLVM and Clang release notes.

  • Updated the side-by-side Dev 16.11 C++ Toolset to version 14.29.30145.00. The latest version of the Dev 16.11 C++ Toolset contains important bug fixes, including fixing all remaining C++20 defect reports. For more information about bug fixes, including C++20 defect reports in Dev 16.11, see Visual Studio 2019 version 16.11.14 release notes.

  • Made various improvements to the in-editor experience of C++ modules. We're continuously working on improving the quality of the experience but encourage you to try them in 17.3. Report remaining issues through Developer Community.

What's new for C++ in Visual Studio version 17.2

For a summary of new features and bug fixes in Visual Studio in version 17.2, see Visual Studio 2022 version 17.1 Release Notes.

  • Added compiler support for C++23 feature deducing this, available under the /std:c++latest option.

  • Added IntelliSense support for C++23 features deducing this and if consteval.

  • Added inline parameter name and type hint support, toggled by pressing Alt+F1 or double-tapping Ctrl. This behavior can be customized under Tools > Options > Text Editors > C/C++ > IntelliSense.

  • Added experimental support for C++20 modules in CMake projects. This support is currently only available with the Visual Studio (MSBuild) generator.

  • In 17.1, we introduced peripheral register and RTOS views for embedded developers. We continue to improve the capabilities of those views with usability improvements in 17.2:

    • The RTOS tool window is now hidden by default. It prevents showing a tool window with error messages that aren't relevant when you're not using an RTOS.
    • When you double-click an RTOS object in the tool window, it adds a watch for the object.
    • When you select the start and end values for the stack pointer in the RTOS tool window, it opens in the memory window.
    • Added thread awareness for device targets to the call stack window.
    • Users can now select a pin icon next to peripherals, registers, or fields to pin them the top of the Peripheral View.
  • Added implementations of the remaining C++20 defect reports (also known as backports). All C++20 features are now available under the /std:c++20 option. For more information about the implemented backports, see the C++20 Defect Reports project in the Microsoft/STL GitHub repository and the MSVC's STL Completes /std:c++20 blog post.

  • We added various C++23 Library features, available under the /std:c++latest option. For more information about the new features, see the STL Repo changelog.

  • Improved performance of the initial C++ indexing by up to 20%, depending on the depth of the include graph.

What's new for C++ in Visual Studio version 17.1

For a summary of new features and bug fixes in Visual Studio in version 17.1, see Visual Studio 2022 version 17.1 Release Notes.

  • A new Configure Preset template is added to configure and build CMake projects on a remote macOS system with CMakePresets.json. You can also launch CMake targets on a remote macOS system, and then debug remotely in the Visual Studio debugger backed by GDB or LLDB.
  • You can now debug core dumps on a remote macOS system from Visual Studio with LLDB or GDB.
  • The versions of Clang and LLVM shipped with Visual Studio are upgraded to v13.
  • Visual Studio's CMake integration is only active when a CMakeLists.txt is identified at the root of the open workspace. If a CMakeLists.txt is identified at another level of the workspace, then you're prompted to activate Visual Studio's CMake integration with a notification.
  • New views that enable you to inspect and interact with peripheral registers on microcontrollers and real time operating systems (RTOS) objects, available through Debug > Windows > Embedded Registers
  • Added a new thread view for RTOS projects, available through Debug > Windows > RTOS Objects. For more information, see Embedded Software Development in Visual Studio.

What's new for C++ in Visual Studio version 17.0

For a summary of new features and bug fixes in Visual Studio, see Visual Studio 2022 version 17.0 Release Notes.

  • The Visual Studio IDE, devenv.exe, is now a native 64-bit application.

  • The MSVC toolset now defaults to SHA-256 source hashing in debug records. Previously, the toolset used MD5 for source hashing by default.

  • The v143 build tools are now available through the Visual Studio installer and in the standalone build tools.

Hot Reload for native C++

  • Hot Reload for C++ makes it possible to make many types of code edits to your running app and apply them without needing to pause app execution with something like a breakpoint.

In Visual Studio 2022, when you start your app in the debugger, you can use the Hot Reload button to modify your application while it's still running. This experience is powered by native Edit and Continue. For more information about supported edits, see Edit and Continue (C++).

  • Hot Reload supports CMake and Open Folder projects.

WSL2 support

  • You can now build and debug natively on WSL2 without establishing an SSH connection. Both cross-platform CMake projects and MSBuild-based Linux projects are supported.

Improved CMake support

  • Upgraded the version of CMake shipped with Visual Studio to version 3.21. For more information on what's available in this version, see the CMake 3.21 release notes.

  • CMake Overview Pages are updated to support CMakePresets.json.

  • You can now configure and build your CMake projects with CMake 3.21 and CMakePresets.json v3.

  • Visual Studio now supports the buildPresets.targets option in CMakePresets.json. This option allows you to build a subset of targets in your CMake project.

  • The Project menu in CMake projects is streamlined and exposes options to "Delete Cache and Reconfigure" and "View Cache."

  • Implemented the /scanDependencies compiler option to list C++20 module dependencies for CMake projects, as described in P1689R5. It's a step towards support for building modules-based projects with CMake and we're working on completing this support in later releases.

Standard Library improvements

Select Standard Library (STL) improvements are highlighted here. For a comprehensive list of new functionality, changes, bug fixes, and performance improvements, see the STL team's Changelog.

  • Added debugging visualizers to improve how the following types are displayed: source_location, bind_front(), u8string (and its iterators), default_sentinel_t, unreachable_sentinel_t, ranges::empty_view, ranges::single_view, ranges::iota_view (and its iterator/sentinel), ranges::ref_view, thread, thread::id, jthread, and filesystem::path
  • Added [[nodiscard]] to the stoi() family of functions in <string> and to various functions in <locale> such as the collate member functions, has_facet(), and the isalnum() and tolower() families.
  • P0980R1 Made std::string constexpr in VS 2019 16.10. Now supported for Clang.
  • P1004R2 Made std::vector constexprin VS 2019 16.10. Now supported for Clang.

Highlighted C++23 features

  • P1048R1 Added is_scoped_enum, a new trait for the C++ Standard library, which detects whether a type is a scoped enumeration.
  • P1132R7 out_ptr(), inout_ptr()
  • P1679R3 contains() For basic_string and basic_string_view
  • P1682R3 to_underlying() for enumerations
  • P2162R2 Allow inheriting from std::variant
  • P2166R1 Prohibit constructingbasic_string and basic_string_view from nullptr. This change is a source-breaking change. Code that previously had undefined behavior at runtime is now rejected with compiler errors.
  • P2186R2 Removed garbage collection support. This change removes declare_reachable, undeclare_reachable, declare_no_pointers, undeclare_no_pointers, get_pointer_safety. Previously, these functions had no effect.

Highlighted performance improvements

  • <format> now detects when it's writing to a back_insert_iterator for a basic_string or a vector, and makes a faster call to insert() at the end() of the container.
  • We improved the performance of std::find() and std::count() for vector<bool> 19x and 26x (times, not percent).
  • We improved the performance of std::count() for vector<bool>
  • std::byte now has the same performance as unsigned char in reverse() and variant::swap()

Clang and LLVM support

  • LLVM tools shipped with Visual Studio are upgraded to LLVM 12. For more information, see the LLVM release notes.

  • Clang-cl support was updated to LLVM 12.

  • You can now debug processes running on a remote system from Visual Studio by using LLDB.

C++ AMP deprecated

  • C++ AMP headers are now deprecated. Including <amp.h> in a C++ project generates build errors. To silence the errors, define _SILENCE_AMP_DEPRECATION_WARNINGS. For more information, see our AMP Deprecation links.

IntelliSense improvements

  • We made improvements in C++ IntelliSense when providing navigation and syntax highlighting for types from imported Modules and Header Units. IntelliSense is an active area of investment for us. Help us improve: Share your feedback on Developer Community by using Help > Send Feedback.

  • We improved C++ IntelliSense performance by optimizing cached header usage and symbol database access, providing improved load times to get into your code.

  • The IntelliSense Code Linter for C++ is now on by default, providing instant as-you-type suggestions and fix suggestions for common code defects.

  • C++ IntelliSense for CMake projects now works when using a preset with a display name.

C++ Workload updates

  • Updated to NDK r21 LTS in the C++ Mobile Development workload.

  • The Game development with C++ workload now installs the latest Unreal Engine with support for Visual Studio 2022.

Code analysis improvements

  • Code analysis now enforces that return values of functions annotated with _Check_return_ or _Must_inspect_result_ must be checked.

  • Null pointer dereference detection is improved in our code analysis tooling.

  • Added support for gsl::not_null to code analysis.

  • Support for Libfuzzer under the /fsanitize=fuzzer compiler option.

Release notes for older versions

Release notes for older C++ versions are also available. For information on what's new for C++ in Visual Studio 2019, see What's new for C++ in Visual Studio 2019. For information on what's new for C++ in Visual Studio 2017, see What's new for C++ in Visual Studio 2017. For information on what's new in earlier versions, see Visual C++ What's New 2003 through 2015.

Known issues

C++ IntelliSense

For more information on other open issues and available workarounds for C++ in Visual Studio 2022, see the C++ Developer Community issues list.

Feedback and suggestions

We'd love to hear from you! You can Report a Problem or Suggest a Feature by using the Send Feedback icon in the upper right-hand corner of either the installer or the Visual Studio IDE, or from Help > Send Feedback. You can track your issues by using Visual Studio Developer Community, where you add comments or find solutions. You can also get free installation help through our Live Chat support.

Blogs

Take advantage of the insights and recommendations available in the Microsoft Developer Blogs site to stay up to date on all new releases. The blogs include deep dive posts on a broad range of features. The C++ Team Blog and the Visual Studio Blog are of particular interest.