MSVC has made significant progress on C++23 features, including implementing consteval escalation, container adapters (flat_map and flat_set), and various language improvements like deducing this, simpler implicit move, and static lambdas. The remaining C++23 feature is constexp Cmath, which uses LLVM's libc library to provide highly accurate and consistent floating-point behavior between compile-time and runtime evaluation, with performance trade-offs that developers must consider.
Deep Dive
Prerequisite Knowledge
- No data available.
Where to go next
- No data available.
Deep Dive
MSVC, are we there yet? Status of C++23 and C++26 features
Added:Hey everyone. Welcome to this year's talk on C++ language conformance. My name is Rand Air. I'm a compiler engineer working on MSVC, and today we'll cover the progress we've made on the final bits of C++ 23 since the last Pure Virtual conference. As part of this feature work, we're also committed to improving compiler quality, namely plenty of bug fixes, better overall conformance where MSVC used to diverge from the standard, uh clearer diagnostics, and we've made significant improvements to code optimization as well, which you can learn more about in our monthly blog posts on the C++ team blog. Now, most of the features we'll demo today are already available in the latest build tools version 14.51.
Some features are in 14.52, which is currently in preview. I'll show you how to install the MSVC preview, and if you want to learn more about that, we have a session from this conference that goes into more detail. Look for Always Be Upgrading Living at Head with MSVC.
And as a disclaimer, we don't plan to release any major C++ 26 language features in 14.52.
So, we won't demo anything from C++ 26 today.
For those tuning in with a particular interest in C++ 26, have no doubt that we share your interest. We'll talk a little more about that at the end. Okay, first here's an overview.
These are the compiler features we're going to demo today. For each one, I've put the toolset version in which it was released, as well as the committee paper number.
I'll admit a lot of the flashier features were shown last year, but there's some gems here you'll enjoy.
On this slide are all the other compiler features we've implemented since last time. Among these, I'll just call out consteval escalation. We completely re-implemented consteval to get this feature in, and that also fixed a ton of consteval bugs for us, especially ones related to stood source location. And as a reminder, you can use any of the features I've listed so far with the stood C++ 23 preview or C++ latest flags. Next, for the standard library, we have shipped the long-awaited container adapters flat_map and flat_set. These were primarily implemented by contributors.
Contributors have also helped implement the C++ 26 features on this list.
Uh these ones are smaller, non-disruptive tweaks that have been applied to older language modes. Now, at the time of recording this, there's only one C++ 23 feature left to finish, constexp Cmath.
Over the past year, our compiler engineer Cody Miller has put an incredible amount of effort into this feature and then some.
Our goal is to have constexp Cmath out by 14.52.
At the end of the demo, we'll take a peek at what's in store and I think it's pretty exciting.
And last thing here, you can track STL progress commit by commit at microsoft.github.io/stl.
Here you can see the pull request activity in white, in blue is the C++ 26 features left to complete, which has been growing as the committee finalizes new features, and in purple, all that remains of C++ 23 is constexp Cmath.
And you can look at the project view to see what's available for contributors to pick up.
All right, let's look at some features.
First though, I'm going to enable the 14.52 preview tool set.
I'm using the latest stable Visual Studio version, which for me is 18.7.3.
I can modify it in the installer and then go to the individual components tab and search for preview.
It's right there. Then, in the general section of my project properties, I'm going to say yes, use the MSVC build tools preview, and that's it.
So, I've been working on this custom query language that allows me to take a stream of data and then query it for information that I want.
Here is a little miniature of that.
How it works is you build a query by chaining together operators and then compiling them into a stood function that you can execute. So, here I have an operator that filters for numbers greater than 42 and an idempotent operator that I want to optimize out.
And we have this data set with some repetition.
We run the query and print the results and we get all the numbers greater than 42 and their duplicates. What I want to do is migrate my code base from C++ 20 to C++ 23. So, we're going to step through it and see what we can change.
Let's just control-click to go to the definition of the query builder in my module. First thing I want to point out is I have this pretty aggressive pound error directive. So, I'm going to demote it to a pound warning, which is new in C++ 23.
This is a how I define the greater operator. It just saves the operator in a vector using this tag union. Now, the query builder is meant to be ephemeral, which is why I'm passing the builder around as an rvalue reference, but I find the return statement kind of cumbersome to write in functions like this. So, in C++ 23, we can use deducing this to put the reference constraints on the explicit object parameter named self.
And now that it's not a pointer, we can write return self. And this is secretly using another C++ 23 feature called simpler implicit move. Uh in C++ 20, we would have had to write stood move here. Now it's a bit cleaner.
Now let's scroll down to the compile function.
It makes a stood function that converts a vector of ints into a vector of ints.
And what I'm doing here is slowly building up a stood function that executes the query.
And needs to have the right type, and you can get that by writing this funky decltype.
Not really my style, but it's something you can do.
And since the query starts as a no-op, we aren't capturing anything, so we'll just mark this lambda as static, which is another new C++ 23 feature. It will make the function call a little more efficient.
Now we're going to process the operators.
And for the sake of demonstration, I'm aliasing the vector of ints type here because we use it later in the function.
And then we do some optimizations on the operator sequence.
And we're doing something called operator fusion.
This one's pretty simple. We just merge adjacent greater than filters.
And we already showed this last year, but we're going to use the C++ 23 feature, which is size_t literals, and use the UZ suffix for our loop index.
Okay, back to the query compilation loop. So now let's upgrade this loop to C++ 23.
We're going to use two features here.
First is we can now declare aliases in the init statement of a ranged for loop.
And then we can rely on lifetime extension in ranged for loops written like this. We actually create a temporary in the result of the fuse call, which in C++ 20 would have been destroyed early and would be causing undefined uh trying to read it inside the loop, but now that temporary is lifetime extended for the duration of the loop.
So, we can compose our function calls all in one place like this.
Okay, back to the main file.
Remember that we had some duplicates in our data. So, let's just use stood flat set to help present the unique elements from our query.
I can easily populate it with the query results and then simply print it out using stood print, which is also new in C++ 23.
And if you're not familiar with flat set yet, one of the advantages is that the elements of the set have stronger guarantees of cache locality.
So, iterating the set should be really fast.
And yeah, here we go. We have the deduplicated result.
And we've got one more little baby demo here just to show off two more features that I think are cool.
First, check out these string literals in this array here. I'm using the new named universal character escape sequence to actually write out the official Unicode names for these characters.
And that's pretty neat. Just mind that with MSVC, you will have to make sure UTF-8 mode is enabled and that if you print it out to your terminal that has the correct code page.
And then one more thing, which is the names that are available to be used depends on the Unicode library on your Windows operating system. So, if some don't exist, it might mean that it needs to be updated. And the last neat feature here is unknown references and pointers in constant expressions. So, at the top here, we have this function which uses template argument deduction to pull out the size of an array.
And this is a great function to have because it means you can avoid writing that, you know, classic C-style size of uh like array divided by size of the element type or whatever it was. And we're using the size function down here in this other function.
And this line is actually an error in C++ 20 because this is a const expert variable, which means its value needs to be computed at compile time.
But the expression of its initializer depends on a variable which only exists at runtime.
So, this was an error because there was simply a hard and fast rule that you're not allowed to even talk about variables that are outside the evaluation context. And C++ 23 uh lifted that uh constraint a little bit to allow us to still pass around the variable so we can talk about its type um so long as we don't try to read from it.
Okay, let's take a little sneak peek at the work we've been doing on const expert C math.
Now, we have a couple goals for this feature. First, we want to set a higher standard for the accuracy of our floating-point functions. The UCRT math functions are good approximations, but there is room for improvement.
And second, we want to guarantee consistent floating point behavior between compile time and run time. We're accomplishing both goals as follows. At compile time, we're using the lib C math library from LLVM.
This library achieves perfect accuracy for all but a few of its functions.
And second, we're also enabling lib C at run time so that the floating point behavior is consistent with compile time.
This feature as a whole will be controlled by a compiler switch. So, if your existing project depends on CRT math results, you can still get those, but you won't be able to use it at compile time.
With the feature enabled, you will get highly accurate and consistent floating point behavior results across compile time and run time.
So, here are examples of UCRT accuracy in the worst case.
These are four different math functions given some input and a comparison of what the UCRT computes versus lib C in hex.
In all of these cases, lib C gives the most accurate result possible for 32-bit float.
And to measure this, we use something called ULP.
Basically, we count how many representable floats a number is from the true value.
So, you can imagine that lib C is like half a bit at most away from the true value.
Whereas, the UCRT, here you can see is usually around two to four floats away from where it should be.
Hopefully, that puts it into perspective.
Now, we should look at the run time performance of this feature because there are trade-offs.
On my machine, I sampled the speed of some 32-bit math functions with the feature disabled and enabled. And the right-most column is the nanosecond difference per call, and then the relative speed up speed down. And this should give you an idea of the spread of perf differences. Some functions might be noticeably faster, some noticeably slower, and some about the same. So, if you do enable const exper cmath, this is something to consider. Libc functions have near perfect floating-point accuracy, and you will have to weigh that against the performance impact on the function you care about.
And I want to point out these numbers do not reflect LLVM's libc by itself.
These numbers come from our own build of libc while this feature's still in development. There's plenty of room for us to fine-tune our build or integrate with the latest changes to libc, and so on. Okay, what about C++ 26?
Well, most likely we'll start with reflection and take it from there.
In any case, please head to our developer community post where you can vote on which C++ 26 features you'd like to see most.
Leave a comment or just an upvote.
Everything counts. Engaging this way is a really important signal that will help us prioritize work that matters to you and matters to us.
You can find that post at aka.ms/cpp26-devcom.
For the STL, we are accepting PRs for non-disruptive C++ 26 features. If you'd like to contribute, check out the active column on our GitHub project. We'll start accepting contributions for more papers once we iron out the repo guidelines and test infrastructure.
Finally, if If like to try out any features or improvements as they come out, install the MSVC build tools preview and let us know how it goes on DevCom.
My name's Rand Air. Thank you for tuning in and please enjoy the numerous other talks here at Pure Virtual C++.
Related Videos

TOP 15 Data compression Interview Questions and Answers 2019 Part-2 | Data compression | Wisdom jobs
wisdomjobs
281 views•2019-06-28

CTS 158: 802.11w Management Frame Protection
ClearToSend
4K views•2019-02-04

NDSS 2019 Send Hardest Problems My Way: Probabilistic Path Prioritization for Hybrid Fuzzing
NDSSSymposium
496 views•2019-04-02

How realistic is Cities: Skylines?
CityBeautiful
159K views•2019-02-14

GUIs & TUIs: Choosing a User Interface for Your Python Project | Real Python Podcast
realpython
2K views•2025-04-04

The OSI Model - Explained by Example
hnasr
225K views•2019-05-12

Cloud Computing - Introduction
elithecomputerguy
98K views•2019-10-07

From Traveler's Dilemma to Dynamic Routing | Demystifying Networking
IITBombayJuly
5K views•2019-08-04
Trending

WOW! Judge TURNS THE TABLES on Trump in His OWN $10B LAWSUIT!!!
MeidasTouch
197K views•2026-07-23

Playstation NO DISC/NO BUY Fight Is Over...
DavidJaffeGames
4K views•2026-07-23

Steam and Xbox Just Dropped The Hammer On PlayStation
OhNoItsAlexx
9K views•2026-07-23

Americans Confused in Australia for 17 Minutes Straight
IWrocker
17K views•2026-07-23