C++ has had three kinds of template parameters since basically always: type template parameters (the vast majority), non-type template parameters (sometimes called value template parameters, which strikes me as a better term), and template template parameters (parameters that are themselves templ...
C++20 Range Adaptors and Range Factories
Ranges in C++20 introduces with it a bunch of range adaptors (basically, algorithms that take one or more ranges and return a new “adapted” range) and range factories (algorithms that return a range but without a range as input). All of these algorithms have several important properties, and I’ve...
Niebloids and Customization Point Objects
C++20 Ranges bring with them several new ideas by way of solving a lot of different problems. Two of the new terms in Ranges, niebloids and customization point objects (or CPOs), are very frequently confused and used interchangeably. This confusion is pretty understandable (the two are pretty si...
Why tag_invoke is not the solution I want
C++ is a language that lauds itself on the ability to write good, efficient generic code. So it’s a little strange that here we are in C++20 and yet have surprisingly little language support for proper customization. It’s worth elaborating a bit on what I mean by “proper customization.” There ar...
Implementing a better views::split
One of the new additions to C++20 courtesy of Ranges is views::split . There are two kinds of split supported: you can split by a single element or by a range of elements. This is an incredibly useful adapter since wanting to split things comes up fairly often. But there’s a big problem with the...
Lambda Lambda Lambda
I like watching Conor Hoekstra’s videos, both because he’s generally an engaging presenter, and also because he talks about lots and lots and lots of programming languages. I don’t know that many languages, so it’s nice to get exposure to how different languages can solve the same problem. A rec...
Implementing span's comparisons
One of the new types in C++20 is std::span<T> (with its fixed- size counterpart std::span<T, N>). This is a very useful type, since it’s a type-erased view onto a contiguous range - but unlike more typical type erasure (e.g. std::function), there’s no overhead. I’ve previous written a...
The constexpr array size problem
Update from 2022: my proposal to address this problem, P2280 (Using unknown pointers and references in constant expressions ), has been adopted for C++23. This issue was first pointed out to me by Michael Park, and mostly explained to me by T.C. Let’s say I have an array, and I want to get its ...
Why were abbrev. lambdas rejected?
In November, 2017, I presented my proposal for abbreviated lambdas (P0573R2) to Evolution in Albuquerque. It was rejected (6-17), though the group was willing to consider future proposals for shorter lambdas which present new technical information (18-2). Since then, there’s been a lot of confus...
Named Template Arguments
C++, unlike many other programming languages, doesn’t have named function parameters or named function arguments. I hope it will someday, it’s a language feature that I find has large benefits for readability. Until then, in C++20, we actually have the ability to do a decent approximation not onl...