February 25, 2020

How I use references

Following a blog post by Herb Sutter, let me tell you how and when I use references. If I do not need to mutate an input parameter, I will use a const reference, unless I know that copying is cheaper (When in doubt use a reference). If I do need a copy of the parameter, I accept it by value and move it If I do need to mutate an input parameter, I will accept an input reference. Read more

February 24, 2020

The Day The Standard Library Died

In Prague, the C++ committee took a series of polls on whether to break ABI, and decided not to. There was no applause. But I’m not sure we fully understood what we did and the consequences it could have. I do believe none of the consequences will be good. What is ABI ABI is the shared understanding libraries have about how your program is serialized, both in term of layout, calling convention and mangling. Read more

February 19, 2020

Shipping C++20 in Prague

C++20 has shipped! C++ is better and more alive than it has ever been. You might have read on the Internet (rarely a good idea), that C++ grows too fast, too complicated, too big. I do not think this is true. Bjarne Stroustrup reminded us that concepts are mentioned in Design and Evolution of C++, a book written in 1994, before even the first C++ standard. Coroutines and Modules are also old ideas that represent more than a decade of work. Read more

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