When you explore a file format, you may find file signatures. A file signature is a sequence of bytes that used to verify the content of a file. A file signature may look as a sequence of “magic by...
Exceptions in C++ and Garbage Collection - what do they have in common? ♻️
I do not mean technical similarity, but the very principle of having a feature of this sort. Initially, the feature looks cool and can be used seamlessly “out of the box”. But when there is a need...
Entry threshold for contributing to compilers
Once in a C++ chat, a guy asked whether it make sense to investigate and send bugfixes to existing compilers? There definitely must be a lot of people who want to fix bugs, and the issues just disa...
The most vexing C++ rule for modular projects (and how to deal with it)
While developing my pet project, I encountered what I call the most vexing C++ rule in my experience, at least for modular programs. It is linker-specific and requires sort of secret knowledge to d...
The simplest std::function explanation in 15 minutes
This post was written under influence of a cool video from Jason Turner “A simplified implementation of std::function” Often people don’t think about how std::function works. Most people know th...
Helping the compiler with [[assume]]
I wrote once about std::unreachable (aka __builtin_unreachable before C++23): link to the post. This command tells the compiler that the program will never get into this branch of execution (the p...
Branch tables for switch operators
In C++, the switch operator is used to transfer the control flow to different locations depending on the value of the given variable. The switch statement is a correspondence between the values of ...
How to discard a [[nodiscard]]
The [[nodiscard]] attribute was added in C++17. It is used to mark functions so that whoever called the function does not ignore the return value. In many environments, any warning breaks compilat...
📚 Book review: "Modern C++ Programming with Test-Driven Development" (2013)
Link to The Pragmatic Bookshelf. Introduction In the last few years, I have elaborated my own rule: the set of tests describes all possible use-cases that the program should be able to accompli...
ABI: the three scary letters 🎃
One of the topics that is hardly noticeable in the world outside C++, but which causes a regular shitstorm among senior C++ contributors is the question of breaking the ABI. ABI (wiki) is a set of...