operator auto

In a previous post on borrow types, I mentioned in passing the idea of operator auto. For the past couple of years, when I’ve used that phrase, I’ve meant something like what’s proposed in Joël Falcou, Peter Gottschling, and Herb Sutter’s P0672 “Implicit Evaluation of auto Variables” (2017). That is, we have some class with a bunch of operators that return expression templates, or perhaps just proxies (like vector<bool>::iterator). Anyway, they return objects of some ugly temporary type, probably containing dangling references.

Read More

Thoughts on “sanely move-assignable”

The “relocate” operation to be proposed in my upcoming P1144 (not yet published) is a high-level operation consisting of a move-construct and a destroy. This is analogous to how most libraries today define “swap” as a high-level operation consisting of a move-construct, two move-assigns, and a destroy.

Read More

Portia’s Caskets, Explained

Via Mark Dominus:

There are two boxes on a table, one red and one green. One contains a treasure. The red box is labelled “exactly one of the labels is true”. The green box is labelled “the treasure is in this box.”

Can you figure out which box contains the treasure? …

Read More

CppCon 2018 Early Bird Registration closes on July 7th

Right now you can register for a full week of CppCon 2018 for the low low price of only $845. On July 7th, early-bird registration closes, and the price goes up to $995.

Some people are probably waiting to see what the program schedule looks like, before they commit to the price tag. If you’re in that category, stop waiting!

Read More

Trivially swappable

This is a recycling of a reply I just made to Mingxin Wang and Gašper Ažman over at std-proposals. TLDR I think “trivially swappable” is a straightforward corollary to “trivially relocatable”, but its cost-of-specification might be a bit higher, and its benefit-in-performance is essentially zero as far as any use-case I can think of.

Read More

The surprisingly high cost of static-lifetime constructors

I was looking at HyperRogue again this week (see my previous post). It has a really nice localization framework: every message in the game can be translated just by adding a lookup entry to a single file (like, for the Czech translation, you add entries to language-cz.cpp); and then during the build process, all the language-??.cpp files are collated together and used to produce a single language-data.cpp file with a lookup table from each English message to the same message in every other language. (Seeing all the messages at once allows us to report on how “complete” each translation is, relative to the others.)

Read More