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”