A Crossword for CppCon 2024

As well as being a C++ enthusiast, I’m a bit of a cruciverbalist. I do the Guardian cryptic every day (not in a particularly competitive time — I’d count sub-20 minutes as a good day), and sometimes others when I can. Like many Brits, I learned to do cryptic crosswords as a teenager. It’s true… Continue reading A Crossword for CppCon 2024

Published
Categorized as C++, Games

std::source_location is Broken

Everyone knows that the best way to get something done on the Internet is with an inflammatory title and a potentially incorrect contention, so here goes. What do you if you want to capture/log the filename of an assertion? Prior to C++20, you use good old __FILE__, which gives you a C-style array of chars.… Continue reading std::source_location is Broken

Published
Categorized as C++

C++23’s new function syntax

We’ve had a couple of ways to spell functions for a long time: And we’ve had a shortcut for that second one for a while, too: (Aside: notice where [[nodiscard]] is positioned, since C++23’s P2173, to apply to the lambda’s call operator.) All these ways to spell functions look the same at the call site.… Continue reading C++23’s new function syntax

Published
Categorized as C++

constexpr Function Parameters

The Set-up In C++, this doesn’t work: The compiler complains, quite rightly: Despite the fact that twice_square is a constexpr function, its parameter x is not constexpr. We can’t use it in a static_assert, we can’t pass it to a template, we can’t call an immediate (consteval) function with it. So far, so well known.… Continue reading constexpr Function Parameters

Published
Categorized as C++

Familiar Template Syntax IILEs

A lot has already been said in the blogosphere about the use of immediately-invoked lambda expressions (IILEs) for initialization, and they’re certainly very useful. In C++20, P0428 gives us “familiar template syntax” for lambdas. Now, instead of writing a regular generic lambda: we have the option to use “familiar template syntax” to name the template… Continue reading Familiar Template Syntax IILEs

Published
Categorized as C++