# Concepts as door-opening robots

I’m at CppCon this week. It’s great. You should be here too. (If you are — come say hello in person! I hope you’re having fun so far.)

# A simpler SUBSUMES() macro

In our previous installment, I called the following (not-yet-valid C++2a) idiom a “poor man’s version” of member concepts:

# A use-case for member concepts and/or template concept parameters

I continue, very slowly, to work on my CppCon 2018 session “Concepts As She Is Spoke.” A while back, someone on the C++ Slack channel asked whether it was possible to have either “template concept parameters” or “member concepts” — that is, either

# Data race when catching by non-const reference

People say “always catch exceptions by const reference,” which I think is good advice. I’ve worked on at least one codebase that catches by non-const reference, presumably just because it’s shorter to type. This has never caused any problem for them in practice, as far as I know. But in theory, it’s a bad idea, because in C++ it is possible to construct a program where two different catch-blocks, executing concurrently, actually reference the exact same exception object. In that situation, any mutation to the exception object will cause a data race. The easiest way to prevent the race is to prevent mutation: to catch by const reference!

# Homeworlds: The Yellowbird Mistake, Part II

Following up on my previous post titled “The Yellowbird Mistake”…

# Homeworlds: The Yellowbird Mistake

This post is about Binary Homeworlds, the “space chess” game invented by John Cooper and popularized by (among others) Andy Looney. You can play Homeworlds online at SuperDuperGames. Sadly a full rules explanation is out of scope for this blog post, but maybe sometime. In this post I just want to talk about a specific tactical error that (sigh) I keep making.

# Constrained forwarding references considered sketchy as frick

I’ll just leave this here.

# The big problems for C++11 SFINAE

So I’ve finally started working on slides for my CppCon 2018 talk “Concepts As She Is Spoke.” (To see the original work to whose title this is an allusion, click through.) I intended to make it as bland and tutorial in nature as I can, but my natural tendency to find the hard problems keeps interfering. Let me take the 25 slides I just wrote and turn them into a blog post, so that I can qualmlessly delete these slides and start over.

# The Mysteries of London

Lately I’ve been reading George W. M. ReynoldsThe Mysteries of London (serialized 1844–1845). Or, mostly, speed-reading; it gives the general impression that the author was paid by the column-inch, and it’s not worth too much of one’s full attention. But every so often there’s a gem that makes the exercise pay off.

# make_range and reversed

A simple force multiplier that should be in every C++11-and-later programmer’s toolbox:

template<class It>
struct iterator_range {
It begin_, end_;
constexpr It begin() const noexcept { return begin_; }
constexpr It end() const noexcept { return end_; }
}; ...


# Stopping the cascade of errors

In 2016, Andrzej Krzemieński pointed out that static_assert is great and all, but it doesn’t stop the cascade of error messages from something like this:

# C++ doesn’t know how to do customization points that aren’t operators

If you’re a C++ programmer and you want to customize the behavior of your class for a certain operation, you’ll have one of two experiences:

# Exploring C++ types with puts(__PRETTY_FUNCTION__)

Today on Slack I noticed that some people still don’t know this one, so it should be shared more widely.

# mutable and “trivially fooable”

Pop quiz, hotshot.

struct M {
M() = default;
M(M&);
M(const M&) = default;
};


Is M trivially move-constructible? …

# The Auto macro

I’ve been talking about this one since 2014. The contents of “Auto.h” fit comfortably on a single slide:

# The FORCE_CONSTEXPR macro

#define FORCE_CONSTEXPR(expr) [&]() \
{ constexpr auto x = (expr); return x; }()