C++26: Standard Library Hardening Experiments

This article explores the concept of 'hardening' in the C++26 standard library, focusing on how it improves safety by replacing undefined behavior with defined contract violations. It explains the technical shift from unchecked access to hardened preconditions.
Why it matters
Hardening is a critical evolution in C++ that aims to mitigate memory safety issues, which are a primary source of security vulnerabilities in software.
"Hardening" seems to be a very popular term in the C++ World in 2026. In this article we'll explore what this word means and see some core examples. Can a hardened library make C++ fully safe? Let's find out.
When you learned about std::vector you may remember that you can access an element at the i -th position using at least two expressions:
std :: vector < int > v { 1 , 2 , 3 , 4 }; v [ i ] = 10 ; // for some i v . at ( j ) = 11 ; // for some j The main difference between those two is that [] is unchecked (and can generate undefined behaviour if you try to access an element which is not there), while .at() may throw std::out_of_range (so it's a well defined behaviour).
Get smarter about the news
Sign up free for a feed built around what you actually care about, Dive Deeper research on any story, and the full text of every article.
Create free accountAlready have an account? Sign in