Clang 20 was released in early March. But there is no rest for the wicked; Clang 21 is poised for a release in September. While we are hard at work on C++23, C++26, and C23 features, I am also trying to find some time to work on miscellaneous bits and bobs. I figured I should talk about some of them even if it’s all listed in the in-progress changelog, which we do our best to keep as…
Someone was giving away stickers reading “Somebody Should Do Something” at the WG21 C++ Standardization meeting held in Wrocław last week, and it makes for a pretty good tagline for that meeting. We are one meeting away from calling C++26 feature complete. The draft will be sent to National Bodies this summer. After that, we will have a couple of meetings to fix bugs and then wait for…
How would you put a 69 meters long, 50 meters tall, 1210 tonnes ship in a museum? A boat so large and so great it sank 100 meters into her maiden voyage? Well, you can’t. But, if you really wanted to build a monument to hubris, unsound engineering requirements, and design by kingship, you could design and build a museum around the Vasa. Entombed in concrete, the Vasa will never sail again
Earlier this month, the C++ committee meeting had its penultimate meeting of the C++23 cycle. It was also the first in-person meeting of the C++23 cycle. This means that C++23 was mostly designed over zoom. Which, sadly, explains in part why the language side of things has been rather stagnant these past couple of years. But a lot of things happened in Kona. I forgot how intense these things were.
DISCLAIMER The following represent my opinions, not that of the C++ committee (WG21), any of its members or any other person mentioned in this article. I think the most fundamental work done by WG21 is trying to answer meta-questions about itself. What is C++, what is its essence, what should we focus on? How to evolve a language with a growing community, a growing committee? A language that is…
In the early 70s, C was created at Bell Labs as a byproduct of the development of UNIX. It quickly became one of the most popular programming languages. But it was not expressive enough for Bjarne Stroustrup. And so, in 1983, as a byproduct of his Ph.D. thesis, he extended C. C with classes was born. At the time, Bjarne Stroustrup understood that a programming language has many components, not…
When he created Go as a knee-jerk Reaction to C++11, Rob Pike proclaimed Less is exponentially more. While it is anyone’s guess what that is supposed to mean, in this blog post we will see how C++20 is less verbose, yet more expressive than prior C++ versions. I am a big fan of concepts-driven designs. The use of concepts leads to less coupled, more generic interfaces that work with more…
A few months ago I presented a few features that I hope will be considered for C++23. I have since then submitted papers for multi-dimensional subscript expressions and ’_` as a variable placeholder. In this article I want to talk about another improvement I would like to see in the next C++ version: Non-trailing variadic template parameters. Indeed, while parameter packs can appear before…
In Prague, the committee adopted To boldly suggest an overall plan for C++23, a paper that lays a list of priorities WG21 should focus on for C++23. The vote was almost unanimous. I voted against it. I figured it would be interesting to explain why. The problem with plans Plans have a nasty tendency to turn into deadlines and expectations. There was an uproar when contracts did not ship (even…
This is both a follow-up to my CppCon talk and the ongoing ABI saga, which I do not expect to end any time soon. I hope this article to be the first in a series I hope to write over the next few months. A quick reminder, ABI is akin to a binary protocol and decides how your types are laid out in memory, how functions are mangled and are called.
In this article, I present a few language features that I am hoping to see in C++23 and which I have deployed to Compiler Explorer. Please note that these features are not part of a working draft and they have not been presented to the C++ committee yet, so it is impossible to comment on whether any of them might land in 23 or not! Auto Non-Static Data Members Initializers A while back I presented…
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.
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…
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…
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…
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…
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…
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…
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.
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…
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…
I was lucky enough to participate in a third wg21 committee meeting in a row, this time in Kona, Hawaii, a mere 13000 kilometers away. Kona As is tradition, Bryce and others wrote a rather thorough trip report on Reddit and you should check it out. However, if you want to read more details about my experience and some of the proposals I find important, please read on (knowing that your time is…
These past few weeks have been quite difficult for me. I have therefore not followed closely the ongoing discussions about C++, ranges, game developers and iota. I’m afraid my current outlook on things is rather cynical and I’ve been told I might be too assertive and opinionated. So, rather than another exercise in quixotism, or a pointless opinion on how best name a function that…
In case you have been napping, in the last installment we talked about modules mapping, and so now we must talk about modules naming. You see, modules have names and names are hard. In this case, names serve to identify uniquely each module used through the program. The end of this article proposes to govern module naming through an official WG21 standing document and I would love your opinion.…
In this blog post, we will talk about modules mapping. Modules mapping is a mechanism by which is a module name is associated with the source file that defines that module’s interface. A module is closed and self-contained. Which mean that for every module name there must exist one and only source file defining that module. Module mapping is not useful to the compiler per-say. By the time…
I don’t like span. Since that article was posted, the committee improved span quite a bit by removing operator== and making it’s size() consistent with that of vector after a lot of discussions. And I mean a lot. What is span: 30 seconds refresher If you have N T laid out contiguously in memory, you can build a span<T> over them. Span being a value type you can move it around, copy it…
As I left Rapperswil earlier this year, I said very firmly that I would not go to the San Diego Meeting. Crossing an ocean to work on C++ 12 hours a day for a week is indeed madness. And so naturally, I found myself in a San Diego hotel straight from the 60s, to do some C++ for a week. With the exception of the author of this blog, all people there are incredibly smart and energetic, and so a lot…
C++ Modules are going through the standardization process and current plans would have them merged in the C++ Standard in time for C++20. They are a great language feature, offering a number of benefits over headers They feel more modern They are much faster to parse They provide protections against macros They provide some protections against ODR violations. I really can’t wait to be able…
Let say you have some struct square you want to compute the area of. struct square { int width; } You could of course do that: int area(square s) { return s.width * s.width; } But, your friend Tony told you to use more functions, so instead you do that int area(square s) { return width(s) * width(s); } int width(square s) { return s.width; } area being the function you really care about it is…
In this article, we talk about Auto Non-Static Data Member Initializers in C++. All code snippet can be tested on Compiler Explorer thanks to Matt Godbolt and the CE team. The clang patch to enable this feature was authored by Faisal Vali 5 years ago, but I have crudely rebased it on top of clang trunk (~ 7.0). In fact, the main motivation for this article is to put this feature in the hand of…
Please take the quick survey on concept syntax at the end of this article. Did you know that the Concept TS was merged into the Working Draft in July 2017, in Toronto? And we are a Planck length away from merging the Range TS in C++20 as well, including a few goodies such as projections, contiguous ranges/iterators and ranges adaptors? We also added a bunch of general-purpose concepts in the std…
This was my first committee meeting. I arrived Sunday morning at Jona, the next town over where I had a lovely AirBnB in a very nice, peaceful suburb. I settled to visit Rapperswil but met some people from Nvidia going to the meeting. So we naturally started to talk about C++. The meeting was to last 6 days and until the very end, we talked about C++, every minute of every hour.
The papers that will be discussed at the next C++ committee meeting are out. The listing contains a number of interesting and controversial papers. Among them, Herbceptions, a number of concurrent concurrency proposals, a proposal calling for major design changes in the coroutines TS, And an easy-to-review, 200 pages long proposal to unify the Range TS in the std namespace. In total, there are…
In C++11, attributes were added as a way to standardized features such as gnu __attribute__and msvc’s __declspec. The language provisions for standard attributes as well as non-standard attributes through the use of namespaces, though the behavior of non-standard attributes was only settled for C++17. And sadly, as of 2018, neither GCC nor MSVC offer their vendor-specific attributes though the…
You may have noticed a number of “What should go in the Standard Library” posts over the last few days. These posts have generated quite a bit of comments on Reddit and discussions on Slack. I hope more people chime in. The conclusion is that we pretty much all agree to disagree on what the STL is or should be. I’m not sure we can even agree on what C++ is.
This is a reply to Guy Davidson’s article “Batteries not included: what should go in the C++ standard library?”. Over the past few years there has been a push to include a graphics library into the C++ standard. It would be something a bit like cairo. Or SDL. The proposal, in its current form, is here In its current state, the library proposal can draw some shapes on a pre-allocated surface, has…
I wrote a series of article where I compile simple Windows and OSX applications from Linux. I hope you enjoyed it. For me, it certainly was quite the journey. Or the beginning of one. There is lot of rooms for improvement and we left some area unexplored, including some other major Operating systems like Android and iOS. I also did not talk about debugging. The open source community is amazing. We…
This is Part 3 on my series about cross-compilation. You can check out part 1 1 and part 2 2 first ! linuxnewbieguide.org You cannot caters to the needs of Windows and Linux users while ignoring the third major, well, second actually, desktop operating system. The Operating System I’m talking about is of course developed and commercialized by a company best known as the one who gave Clang to the…
This is Part two of a series wherein we build a “Hello World” application. If you are late to the party, I encourage you to check part 1 first. Hic Sunt Arcūs So, our Boss came in to check on our progress. They were starting to wonder why it takes a whole day to port a 3 lines application to a new system. But the real reason of their visit was to ask for a new feature.
#include <iostream> int main() { std::cout << 'Hello, World\n'; } Nothing to remove, nothing to add. This is the proper “Hello World” in C++. All the others Hello World are wrong. But this is not where I rant about how using namespace std; crystallizes everything messed up with the teaching of C++. Another time perhaps. Today we are gonna be compiling that hello world so that it can be executed on…
Your modifications fix the calculation But I’m afraid you forgot a tabulation. This is the beginning of your tribulation. Your perfect correction won’t bring you elation. If there was a way to just automate, Maybe you could avoid arguing with your mate. Should there be a space after the bracket How many white spaces, How many line breaks Did you know tools could format your troubles away? You have…
There are only two kinds of languages: the ones people complain about and the ones nobody uses — Bjarne Stroustrup I like that quote. it explains both JavaScript and Haskell. And by that measure the preprocessor is a great language in that people use it, a lot. It’s never considered separately from C and C++, but if it was, it would be the number one language on TIOBE. The preprocessor is both…
A friend had a phone interview for a job in a company that I won’t name It’s Microsoft. One of the questions was about describing how he would write a stack, only using standard queues. I was confounded, because long before an algorithm could form in my mind, I already decided that there was no solution that would actually be useful in any real life scenario. template <typename T, typename…