February 18, 2020

move, even more simply

std::move doesn’t move. It casts to an rvalue-reference, which is a type of reference that can be passed to a move constructor or assignment operator, if one exists. template <typename T> decltype(auto) move(T&& a) { return static_cast<std::remove_reference_t<T>&&>(a); } Some expressions will be converted to rvalue-references automatically, when the compiler is certain that the value is expiring (will not be reused). This is the case for temporaries or non-reference objects returned from functions. Read more

January 31, 2020

A Universal I/O Abstraction for C++

This article is the sequel to A Universal Async Abstraction for C++, in which I talk about the Executor proposal targeting C++23. Quite a bit happened since then. SG-11, the study group charged of all things concurrency and parallelism made forward progress and sent the proposal to LEWG - with the hope of landing a future revision in the C++23 draft. This is rather big news given that this work has been brewing for about a decade. Read more

January 6, 2020

Waiting for std::embed: Very Large Arrays in Clang

Before we start This blog post features iframes, interactive SVG files, and graphs which may not render properly on handheld devices. Sorry about that. The charts are however interactive, so you can zoom in an see the exact values. If I were a compiler, I would simply put all your bytes in your binary There have been a few interesting and passionate discussions about std::embed lately. std::embed would surely be a great tool to have in one’s toolbox, and I’m sure some version of it will be adopted in time, once a consensus in reach (I have yet to find someone not sold on the usefulness of that proposal). Read more

December 11, 2019

Storing Unicode: Character Name to Codepoint Mapping

Unicode Characters have a name, which makes it easier to talk about them without having to know their codepoint. For example, the character λ (U+03BB) is called GREEK SMALL LETTER LAMDA. Given a character name, we want to be able to know its code point. There are a few use cases for that, the main one being to be able to put Unicode characters by name in string literals, a feature offered by Python, Perl and Perl 6 Raku. Read more

October 30, 2019

A Universal Async Abstraction for C++

Executors - of which P0443R11 is one of the latest iterations - is poised to be the most fundamental library addition to C++23. But what is it about? It is first and foremost a quest to find the most basic building blocks on top of which one could build asynchronous, concurrent and parallel code, whether it be on a small chip or a supercomputer with thousands of CPUs and GPUs. Read more

August 17, 2019

C++ compilation: Fifty shades of Mojibake

Interestingly, writing was initially invented as a way to keep track of numbers. Words came much later. Computers are good at numbers. It’s the only thing they understand really. So text has to be represented as a sequence of numbers which are interpreted and ascribed meaning. Code, in the presence of arbitrary identifiers and string literals as to be considered as text. In the context of C++, how is the text of our program interepreted and transcoded during compilation? Read more

April 27, 2019

Characters sets: A bad idea since the bronze age

You who shall hereafter see this tablet, which I have written, or these sculptures, do not destroy them, but preserve them so long as you live! In 522 BC, 𐎭𐎠𐎼𐎹𐎢𐏁 also known as Dārīus was king of the Persian Empire. Kings crave fame as they do power and so Darius (who the greek later called Δαρεῖος) had his henchmen carve his name in stone. One such stone is the Behistun Inscription, which is really more a mountain than a stone. Read more