New C++26 features to make use of today

The latest C++ Standard has recently been finalized and compiler support, especially in Clang, is progressing rapidly. (The code in this article was tested on Clang 23 with -std=c++2c, while all of the sample error messages are also from Clang.) This article adds to previous ones on this site about C++26 and aims to demonstrate four new additions to the language (as opposed to the Standard Library) that will make your code cleaner and safer.

Continue reading “New C++26 features to make use of today”

String interpolation in C++26

This bite-sized article explores the latest Standard’s support for Python-style f-strings (having a literal f prefix) in C++. This may seem like a strange feature to add, but if you use Python, chances are you already find them invaluable when mixing (or interpolating) values, such as variables and expressions, with static output, such as descriptions. So without further ado, let’s jump straight into the syntax with some simple applications.

Continue reading “String interpolation in C++26”

Language-level assertions in C++26

Assertions (run-time checks of a Boolean condition) have been around since the beginnings of the C language, and are of course available to C++ from the <cassert> header. Starting with the latest Standard, C++ supports a more flexible and featured approach to assertions, with the new language keywords pre, post and contract_assert. This article is intended to provide a walkthrough and quick-start to using these keywords in Modern C++ code, and hopefully explains some of the aims and rationale behind their names and functionality.

Continue reading “Language-level assertions in C++26”