Erroneous behaviour has entered the chat

The C++ language defines the observable behaviour of a program and uses terms such as ill-formed or undefined behaviour to describe it. The C++26 standard introduces a new one, called erroneous behaviour. In this post, we’ll look at what these terms mean. Well-formed This is the simplest of them all. It means that a program … Read more

Modern C++ Programming Cookbook – Third Edition

The Third Edition of my book, Modern C++ Programming Cookbook (ISBN 978-1835080542) has been published by Packt. The book can be ordered from Amazon and Packt. The book is organized in recipes, much like a cookbook. These recipes, in turn, are organized in sections that introduce you to the topic, list any necessary pre-requisites and … Read more

Formatting Text in C++: The Old and The New Ways

When it comes to format a piece of text in C++ there are several ways you can employ: I/O streams, particularly std::stringstream with stream operations (such as operator <<) printf family of functions, particularly sprintf the C++20 format library, particularly std::format / std::format_to any 3rd party library, {fmt} in particular (the source of the new … Read more

How to convert an enum to string in C++

Enumerations are widely used and we often need to convert enum values to strings (typically for recording values in logs) but there is no option at the language level or a utility in the standard library to make it possible. Therefore, developers are usually handcrafting their own solutions. Let’s say we have the following enum: … Read more

Notes on std::optional’s monadic operations

The C++23 standard includes several new functions to the std::optional class: and_then, transform, or_else. These are monadic operations and are intended to simplify the chaining of several operations that may or may not produce a value. In this post, I want to briefly present these functions and to make some observations on them. A starting … Read more

Using Microsoft Edge in a native Windows desktop app – part 5

This article is a new installment in the series about using the Webview2 control in a native application. In this post, I will show how to execute a JavaScript script. Articles in this series: Part 1: Introduction to Edge and WebView2 Part 2: Creating a WebView2 component Part 3: Navigation and other events Part 4: … Read more

The C++23 standard break-down

It’s almost the eve of 2023 and the C++23 standard is feature complete for some while. At some point next year, the new standard version will be formally approved and we will officially have a new version of the standard. But compilers and library implementors are already supporting some of the new additions (or updates) to the standard. If you haven’t been following closely the evolution of C++23 you are probably wondering what’s in this new version.

In this article, you will find a list of the most significant changes to the standard. There is actually quite a long list of proposals that have been accepted . Yet, some of these are things that you won’t use that often; on the other hand, many are defect reports, meaning they are fixing an issue introduced in a previous version of the standard.

Read more