# Homeworlds: Mini Doomsday Machine

Ray’s red homeworld is armed to a frankly ridiculous degree, but all for naught: Lee’s mini-Doomsday-Machine is almost complete and his victory is assured. …

# The Case of Willie the Wisp

As a kid, I’d sometimes read a story where one line has stuck with me over the years as the perfect expression of some archetype. I find myself wishing that other people knew these same stories, so that I could actually use these lovely shorthands.

# The “OO” Antipattern

For those who only read above the fold: I don’t say that all object-orientation is bad! OOP, especially classical polymorphic OOP, has a well-deserved place in real code. I’m going to talk about a very specific antipattern that I see with some frequency: the use of class for things that should be simple free functions.

# Folding over operator=

Jonathan Müller posted a “Nifty Fold Expression Trick” the other day:

template<class F, class... Ts>
void reverse_for_each(F f, Ts... ts) {
int dummy;
(dummy = ... = (f(ts), 0));
}


For example, reverse_for_each(putchar, 'a', 'b', 'c') prints cba.

However, as I puzzled out each step of the process, I realized that there were several subtleties to this “simple” expression! …

# C++Now 2020: A C++ Magic Trick

Today would have been the first full day of C++Now 2020 in beautiful Aspen, Colorado… if not for coronavirus. I had had a good idea for a lightning talk — okay, maybe not as good as “Boost.Blockchain,” but — too good to lose. So I’ve recorded my lightning talk at home and uploaded it to YouTube! You can find it here.

# Connect Fifteen

Here’s a simple two-player card game you can play while stuck at home. I invented it sometime before 2003 — I would guess circa 1999. I call it “Connect Fifteen.”

# Default function arguments are the devil

If you frequently talk with me about C++, you have undoubtedly heard me say:

Default function arguments are the devil.

My position opposes the historical (early-1990s) style of the STL, of course; but I was recently alerted that it’s also in direct conflict with the (2010s) C++ Core Guidelines, specifically rule F.51. Since this conflict might, if unaddressed, lead people to think I’m wrong, I’d better address it. ;) …

# Hello Muddah, Hello Faddah (Coronavirus Version)

So I guess all the cool kids are writing coronavirus-quarantine-themed musical parodies? Here’s my contribution.

# What I’m reading lately: The Compleat Boucher

The other day, prompted by someone’s question on SciFi Stack Exchange, I tracked down Anthony Boucher’s short story “Q.U.R.” It first appeared in the March 1943 Astounding Science Fiction, but today you can find it in The Compleat Boucher (2013).

# A seasonal followup to “When is *x also &x?”

Yesterday I wrote:

• Teach the logic behind C-style declarations. int *p can mean “p is an int*,” and it can equally well mean “*p is an int.” int const *f() can mean “You aren’t allowed to modify the int,” or it can equally well mean “You aren’t allowed to modify *f().” (Of course this only works for pointers, not references; that’s another reason it’s important to reveal pointers early.)

In the Reddit comments, commenter “redditsoaddicting” pointed out that this logic even works for multiple declarations on the same line:

In int *p, q;, the expression *p, q is of type int.

Not only that, but after const int& x(), *y;, we find that decltype(x(), *y) is const int&! …

# Discrete Peaceful Encampments, Bernie Sanders version

Previously on this blog:

# c_str-correctness

I’ve already blogged about one difference between std::string and C++17’s std::string_view: string is owning and string_view is non-owning (being what I call a “parameter-only type”). Today I’d like to talk about a second difference: string is null-terminated and string_view is not.

# Ways C++ prevents you from doing X

C++ has many orthogonal ways of preventing you from doing what you asked for. When I’m doing training courses, I often find students confused (without necessarily knowing they’re confused) between these various failure modes. So I thought I’d write down the most common ones in a blog post.

# The Tau Manifesto

Your Pi Day festivities may have been canceled this year, but get ready to celebrate Tau Day on June 28th!

# Contra char *argv[]

Language warning.

# The Design of Everyday Things

Today I re-read Don Norman’s 1988 book The Design of Everyday Things. I continue to highly recommend it to anyone who does engineering (especially software engineering). In particular, it’s the book that introduced me to the term affordances, as in “glass affords seeing-through, and breaking; a flat panel affords pushing but not pulling.” I felt like the term started to break out into the mainstream C++ community at CppCon 2019, what with its forming the core of my “Back to Basics: Type Erasure” and also being name-dropped by Titus Winters in the B2B track’s closing keynote “What is C++?”

# Field-testing “Down with lifetime extension!”

I hacked my local Clang to produce a warning every time Sema::checkInitializerLifetime detected that lifetime extension was necessary.

test.cc:31:16: warning: binding temporary of type 'int' to a reference