Skip to content

C++ Stories

"Hardening" seems to be a very popular term in the C++ World in 2026.

C++ Stories screenshot

About C++ Stories

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).

In C++26, the Standard introduces the notion of a hardened implementation . Whether a standard-library implementation is hardened, and how that mode is enabled, is implementation-defined.

In other words, if you switch this "hardened" mode you'll get some well specified error/violation rather than just an undefined behaviour.

For .at() you may get an exception… so why do we need a new alternative? That's fair question. In short at() and [] has different interfaces and performance/error-handling approaches. What's more important you cannot turn exceptions off easily (you can, and std::terminate will be called, but that's not very flexible).

So Hardening does not change operator[] into at() - it detects a programming error and terminates instead of allowing memory-unsafe undefined behaviour.

"A contract violation occurs" - this is the key thing here. The "hardening" feature is expressed in terms of Contracts that also were accepted into C++26.

Discussion

Sign in to join the discussion.

Loading comments…

Tagged

Alternatives to C++ Stories

Tools in the same space, ranked by how they are performing in the directory.

Compare all
  • Texbrain

    FOSS browser-based LaTeX editor with live preview, on-demand packages and git integration.

    Open source/Writing & Content
  • TexLite

    TexLite: Lightweight self-hosted collaborative LaTeX editor and Overleaf alternative - SWUFE-DB-Group/TexLite

    Open source/Developer Tools
  • Unsung

    A blog about software craft and quality

    /Writing & Content
  • Lg C5 Webos25 Region Change

    Contribute to hawshemi/lg-c5-webos25-region-change development by creating an account on GitHub.

    /Writing & Content
  • Manual do Usuário

    LibreOffice 26.8 became the app’s most popular update, with over 1 million downloads, after the foundation behind it declared that LibreOffice doesn’t come wit…

    /Writing & Content
  • ChatGPT Text, C2PA, EXIF

    Free AI watermark checker and detector.

    /Writing & Content