What if your function could tell the compiler: "don't call me with a negative number"?
And what if the compiler could actually enforce that at debug time, at test time, or even in production?
C++26 just made that part of the language ๐งต๐
Contracts (P2900) ship in C++26. Preconditions, postconditions, and assertions built into the language, not hidden in comments
Four enforcement modes: ignore, observe, enforce, quick_enforce. Your call, per build
By @timur_audio, Joshua Berne, and Andrzej Krzemieลski
C++ just got a new operator
It looks like this: ^^
The committee calls it "the cat-ears operator." It's the gateway to the biggest language change since templates ๐งต๐
C++26 ships compile time reflection (P2996). The ^^ operator turns any entity (type, function, enumerator) into a compile-time mirror you can inspect and transform
Enum-to-string? One function. JSON serialization? No macros. By @BarryRevzin and six co-authors
You have a variant<Dog, Cat, Raccoon>
You also have an enum { Dog, Cat, Raccoon } that you manually keep in sync with it
One day someone adds Fox to the variant but forgets the enum. The switch compiles and the bug ships
What if the enum wrote itself? ๐งต๐
When you write co_await f() in C++, three questions need answers:
Which thread resumes you? Should you stop? Where does the frame get allocated?
Right now every coroutine library answers these differently. There's a proposal to unify them
P4003 by @FalcoVinnie, Mungo Gill, and Steve Gerbino proposes IoAwaitable: a minimal coroutine execution protocol
Implemented on three platforms. Designed as a companion to std::execution, not a replacement
Every C++ developer has a cursed shell script somewhere that converts a binary file into a C array so it can be compiled in
bin2c. xxd. Platform specific linker hacks. Custom CMake incantations
C++26 just killed all of them. One preprocessor directive
C++26 ships #embed. Pull any file into your binary at compile time. Shaders, fonts, certs, model weights. One directive, no tooling hacks
By @__phantomderp, who's been pushing this since 2018. Already in GCC 16.1 and Clang