July 19th, 2024

New Features in C++26

The ISO released new C++ standards on a three-year cycle, with C++26 proposals open until January 2025. Updates include hazard pointers, user-space RCU support, debugging headers, and template enhancements for improved functionality.

Read original articleLink Icon
New Features in C++26

The ISO has released new C++ language standards on a three-year cycle, with C++26 proposals open until January 2025. Notable additions include hazard pointers for lock-free concurrent code and user-space RCU support. These features are already available for experimentation in GCC and Clang. The proposed hazard-pointer library involves retiring shared objects atomically to manage object reclamation. User-space RCU, widely used in the Linux kernel, allows safe object updates through pointer swapping. C++26 also introduces smaller changes like a debugging header, linear algebra features, and text encoding enhancements. Core language changes include defining infinite loops as defined behavior and allowing void* casting in constexpr. Template improvements involve indexing packs and using them in friend declarations. These changes aim to enhance C++'s functionality and maintainability. The upcoming C++26 standardization meetings are expected to approve these changes, offering a window for feedback and additional suggestions.

Link Icon 6 comments
By @pjmlp - 5 months
I love how the comments section quickly goes into "better fast benchmark winning code with surprising unexpected side effects" than "working code that is fast enough".
By @bun_terminator - 5 months
And this is just the "small stuff". C++26 might land reflections, std::execution and contracts in one go - which would make this mighty
By @signa11 - 5 months
to me at least, hazard pointers and rcu seems to be the major changes, for library authors anyways.

i would actually wager that rcu in and of itself is almost at par with atomics and the memory-model :o)

for folks wondering about 'hazard-pointers' this paper https://web.archive.org/web/20171104135736/http://www.resear... is quite useful as an excellent starting point.

By @8474_s - 5 months
The Template pack index is going to make meta-template variadics much easier. Usually this is prone to cludges like converting parameters to structs or filtering them with functions holding the pack.