C++ Language Updates in MSVC in Visual Studio 2022 17.14 - C++ Team Blog (original) (raw)

May 6th, 2025

heart5 reactions

Cameron DaCamara

Principal Software Engineer

Introduction

In this update, we continue the tradition of bucketing bugs into helpful categories for you all to filter through along with even more notes from the compiler team as to what, exactly, was fixed. This blog is also complemented by the recent Pure Virtual C++ pre-conference talk by RanDair Porter; so please check out RanDair’s talk, “MSVC C++23 Conformance”, if you have not already to get a better view of MSVC’s conformance status for Visual Studio 2022 overall.

17.13 notes for reference.

C++23 Features

Note: C++23 features can be used by either adding /std:c++latest or/std:c++23preview to the command line. In addition, features used from unfinished standards may not have full IntelliSense support.

auto lambda = [] constexpr { }; // C++23: can now omit the '()' after the capture list.
constexpr int f(int) {
  if consteval { // C++23: previously this would be 'if (std::is_constant_evaluated()) { ... }'.
    return 42;
  }
  else {
    return 1337;
  }
}
int main(int argc, const char**) {
  static_assert(f(0) == 42);
  int x = f(argc);
  if (x != 1337) // Since 'f' cannot be evaluated at compile-time, the value here is '1337'
                 // due to taking the 'else' branch in 'f'.
    return 1;
}
enum Flags { Zero, One, Two };
static_assert(One | Two);
auto lambda = [] [[nodiscard]] [[deprecated]] { return 10; };
void f() {
  lambda(); // C++23: Attributes here will fire a deprecation warning and a discard of return value warning.
}
struct Functor {
  static constexpr int operator()() { return 42; }
  static constexpr int operator[](int) { return 42; }
};
using T1 = decltype(Functor::operator()());  // C++23: Deduces to 'int'.
static_assert(Functor::operator()() == 42); // C++23: Can be used without creating a 'Functor' object.

using T2 = decltype(Functor::operator[](10));  // C++23: Deduces to 'int'.
static_assert(Functor::operator[](10) == 42); // C++23: Can be used without creating a 'Functor' object.

Smaller C++23 Items

Compiler improvements for 17.14

C++/CLI

Diagnostics

constexpr

C++ Modules

Conformance

Reliability

Correctness

Correctness (C compiler)

Author

Cameron DaCamara

Principal Software Engineer

Principal Software Engineer, MSVC compiler front-end team at Microsoft.

Stay informed

Get notified when new posts are published.