Multiplying matrices in C++

I have recently come across a (click-bait) post on X claiming that multiplying two 1000×1000 matrices in Python was several times faster than in C++ or other languages. So how do you multiply matrices in C++? Let’s see. First of all, how do you multiply matrices? It’s pretty simple: Here, c11 is computed as follows: … Read more

Universally Unique Lexicographically Sortable Identifiers (ULIDs)

In my previous post, I talked about time-based universally unique identifiers – UUID v7 for short. An alternative to UUIDs (especially to version 4) is the ULID, which stands for Universally unique Lexicographically sortable IDentifier. These are similar with UUIDs, they have the same 128 bit length, but offer several advantages. Let’s see what these … Read more

Time-based Universally Unique Identifiers (UUIDs v7)

Universally Unique Identifiers (UUID for short) are 128-bit numbers with a high degree of unicity so that the possibility of collision is extremely low. They are used for various purposes such as identifying resources, correlation IDs in logging and tracing, primary keys in databases, and more. UUIDs are known as GUIDs (Globally Unique Identifiers) on … Read more

What’s new in C++26 (part 2)

In a previous blog post, I talked about several features included in C++26: specifying a reason to delete a function, placeholder variables with no name, structured binding declaration as a condition, and user-generated static_assert messages. In this post, I will continue exploring the new features that have been already included in the C++26 standard. #embed … Read more

What’s new in C++26 (part 1)

The C++26 version of the C++ standard is a work in progress, but a series of language and library features have been already added. Furthermore, some of them are already supported by Clang and GCC. One of these new changes was discussed in my previous article, Erroneous behaviour has entered the chat. In this post, … Read more

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