What’s New for C++ Developers in Visual Studio 2022 17.14 -- Sy Brand
Visual Studio 2022 version 17.14 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.
What’s New for C++ Developers in Visual Studio 2022 17.14
by Sy Brand
From the article:
We’ve made a myriad of fixes and improvements to the MSVC compiler and standard library. See C++ Language Updates in MSVC in Visual Studio 2022 17.14 for a full list of changes on the compiler side, and the STL Changelog for all the standard library updates.
Compiler
We’ve added support for several C++23 features, which are available under the
/std:c++latest
and/std:c++23preview
flags.You can now omit
auto lambda = [] constexpr { }; //no '()' needed after the capture list()
in some forms of lambdas that previously required them, thanks to P1102R2:
We implemented if consteval
, with which you can run different code depending on whether the statement is executed at compile time or run time. This is useful for cases where your run time version can be heavily optimized with compiler intrinsics or inline assembly that are not available at compile time:
constexpr size_t strlen(char const* s) {
if consteval {
// if executed at compile time, use a constexpr-friendly algorithm
for (const char *p = s; ; ++p) {
if (*p == '\0') {
return static_cast<std::size_t>(p - s);
}
}
} else {
// if executed at run time, use inline assembly
__asm__("SSE 4.2 magic");
}
}