# Another requires-clause syntax pitfall

In my CppCon 2018 talk “Concepts As She Is Spoke,” I presented some pitfalls in requires-clause syntax, such as:

template<class T>
concept HasHash = requires (const T& t) {
t.hash() -> std::integral;
};

struct X { int hash() const; };
static_assert(!HasHash<X>);


On the cpplang Slack today, John Eivind Helset and Eugenio Bargiacchi (inadvertently) showed me a new trap I hadn’t seen before: …

In Bjarne Stroustrup’s paper P0557R1 “Concepts: The Future of Generic Programming” (January 2017), section 6 is titled “Concept Overloading,” which Stroustrup distinguishes from the traditional approach “using helper functions and tag dispatch.” More subtly, Stroustrup seems to distinguish between true “overloading” (asking the compiler to resolve among multiple viable overloads) and other means of giving-two-things-the-same-name:

Where we cannot overload, we need to use workarounds (e.g., traits, enable_if, or helper functions).

I’ll present two problems, each with two solutions (one in C++11 and one in C++20), which I think illustrate something interesting about “concept overloading” versus… other things. …

# A Night of Serious Drinking and operationalism

A few weeks ago, I read René Daumal’s A Night of Serious Drinking (published as La grande beuverie 1938; translated by David Coward and E.A. Lovatt 1979). I recommend it; it’s a fun and erudite satire — sort of a less political Gulliver’s Travels or a less bitter Jurgen. At times it made me think, “This is clearly an allegory… but of what?” and at other times “Is he satirizing bad scientists, bad writers, bad artists? or all scientists, all writers, all artists?”

# C++ On Sea 2021 schedule announced

The schedule for C++ on Sea 2021 has been announced! The “conference day” involves two tracks of five talks each, plus a keynote by Barbara Geller and Ansel Sermersheim. The two “workshop days” offer… well, you should sign up for my own two-day training class, at which point the other offerings are moot. But, just for the record, the two available two-day classes are:

If you don’t do a two-day class, then on Wednesday you can choose among these options: …

# Overly interoperable libraries, part 3

Previously on this blog:

Jason Cobb has sent me a proposal that I think meets all the requirements and therefore qualifies as a complete solution!

Unlike the ideas in my previous posts, Jason’s solution doesn’t depend on “GUIDs” at all. It’s based on a simple idea that is, in hindsight, quite obvious. …

# The Fishspear priority queue algorithm

I continue participating in Zartaj Majeed’s book club on Knuth’s The Art of Computer Programming, previously mentioned in “Bubblesort, rocksort, cocktail-shaker sort” (2020-12-13). The past couple of weeks, we’ve been looking at section 5.2.3, “Sorting by selection,” in which the problem of repeatedly selecting the max element leads Knuth to investigate priority queues.

# Overly interoperable libraries, part 2

I’ve received a few proposed solutions re “Overly interoperable libraries” (2021-05-19). It’s become clear that I set the initial goalposts a little too close to the kicker. :)

# A metaprogramming puzzle: Overly interoperable libraries

Here’s an open problem I posted in the cpplang Slack the other day. I don’t claim that it’s a realistic or practically interesting problem, mind you! But it’s a metaprogramming problem that I think ought to have some clever solution; maybe if I blog it, someone will tell me what that clever solution is.

# “Modern STL Programming” at C++ On Sea 2021

It’s almost time for C++ On Sea 2021! This three-day all-remote conference runs June 30th through July 2nd, 2021. This year it consists of just a single day of conference presentations, preceded by two days of online “workshops” — long-form half-day, full-day, or two-day classes. One of those two-day classes will be Arthur O’Dwyer on “Modern STL Programming: Algorithms, Containers, Iterators.”

# Play The Search for Almazar online

In a previous post, I explained how I’d become aware of Winston M. Llamas’s circa-1981 text adventure game The Search for Almazar; googled up two different versions of its BASIC source code and gotten one of them running in a CP/M emulator; and put that source code and instructions on my GitHub (github.com/Quuxplusone/Almazar).

Three days later, I’ve produced a C99 port! You can compile it natively from the C source, or — better — you can play it online. Let me know if you find any bugs! …

# Nifty notebooks, and Almazar

Thanks to my posts on Castlequest, I’ve been receiving the occasional email from people with memories of the game. Most recently, I received a message from John P. Wesson (RPI classes of ‘71, ‘76, and ‘88). He’d seen the Castlequest news via the wrpi-alumns mailing list, and wanted to share copies of his notes on Castlequest and two other games, made “while babysitting lab equipment during 24-hour runs” as a grad student in the 1980s.

# An interview with Arthur O’Dwyer

You might have noticed in your news feed recently a piece by David Cassel for TheNewStack.io, titled “Software Developer Tracks Down Code for a Beloved 41-Year-Old Text Adventure” (2021-04-25). The piece was based on “an email interview,” which is a bit of journalistic newspeak that means “David sent me an email 36 hours before deadline; I responded.” (Not that there’s anything wrong with that!) Anyway, it’s a good piece of promotion. But I did tell David at the time that since I’d gone to the trouble of writing up a long-form reply, I’d probably put it up on my blog at some point… And now here it is.

# Removing an empty base class can break ABI

Earlier this week Eric Fiselier pointed out something that came as an unpleasant surprise (to me, at least): Even though C++11 deprecated inheritance-from-std::unary_function, and C++14 deprecated inheritance-from-std::iterator, the actual library vendors cannot remove those deprecated relationships from their libraries without taking an ABI break!

# P2266’s interaction with decltype(auto)

C++Now 2021 is happening this week. Normally it’s in Aspen, Colorado, but this year it’s completely online. I presented two talks: “When Should You Give Two Things the Same Name?” and “The Complete Guide to return x.”

In my return x talk, slide 77 showed a table illustrating how P2266’s value-category changes affected five subtly different functions. One of the entries was incorrect; and, as I fixed it, I realized that for completeness the table should have included eight subtly different functions!

Here is a revised and I hope fully correct version of that table. …

# Optimizing string::append is harder than it looks

Back in early March, Lukas Böger asked on StackOverflow: “Where do standard library or compilers leverage noexcept move semantics (other than vector growth)?” So I got nerdsniped into looking at all the places libc++ tests the noexceptness of any user-defined operation. This circuitously led to my finding an absolutely massive number of corner-case bugs in libc++’s string::append member function.

# Lineup for next week’s Celebration of Mind

Next week, April 18 through 24, the Gathering 4 Gardner is hosting a week-long Celebration of Mind, featuring three brief presentations per day, every day. The speaker lineup has just been announced; but since the official website requires multiple clicks to get to the schedule, and is a little verbose too, here’s a very short summary lineup.

# Antisocial Homeworlds, and a solitaire challenge

A couple of weeks ago, I came up with a new variant of Binary Homeworlds. Readers of this blog will already know Homeworlds as the “space chess” game played with colorful pyramids, invented by John Cooper, and popularized mainly by Andy Looney. In fact, this variant was directly inspired by a variant invented by Andy Looney in February 2021, which he called “Peaceful Homeworlds,” and which you can read about here.