The Best C++ Library
71 points by asb
71 points by asb
This post makes me happy!
It feels a bit pointless, because why would anyone want to create a STL
replacement in a (what seems like a) non-corporate context. I don’t see it
gaining real traction. On the other hand, the author clearly cared about this
and knows their stuff. There are some wonderful touches in there, like the
.match
on their sum types. It’s far from done but it seems well thought out
(so far), I’d prefer it to my daily C++ at work.
Still, no one will rewrite a code base using their library, because at that point might as well RIIR.
Also, I didn’t know the monospace font they use (spline sans mono), I’ll have to try it.
I don’t see it gaining real traction.
It’s not a product, it’s performance art!
Rather than trying to coexist with the standard library, I want to surpass it. As a form of performance art, I want to discover what the standard library would look like if we designed it today, in 2025.
I could imagine using it in a new green field C++ project, by forking it and modifying it to suit the needs of my project.
A similar effort was recently described here.
For my hobby C++ projects, I avoid using the standard library, including rolling my own versions of vector/unordered map/tuples, and so on. Probably too extreme of a position, but it helps in keeping compile times down and compiler error messages relatively manageable.
Well I can’t say they’re not ambitious enough!
mods: link has a #fnref:terrible-people
at the end which should be removed.
Oops sorry about that. Thank you in advance to the mods for fixing this - I can’t correct the URL myself it seems.
Am I the only one who thought his code coloring scheme with “blue flame”/judicious green/yellow/etc. was also off the beaten path beautiful? :-) Someone somewhere probably gave such a “name”, but I don’t know it.
I think it might cause problems later down the line to call the btree-backed associative array type just “tree” without any additional qualifiers.
The special format
{:!}
“forwards from above”; when used in a formatting implementation, it uses the format specifier the caller used. This is useful for causing formats to be “passed through”, such as when printing lists or best::option.
I don’t follow, how does the caller specify it?
I think what happens is that when your collection/wrapper type implements BestFmt, it’s passed a formatter
(as “fmt” in examples), which stores what the current format specifier is. So if you implement BestFmt for a list of ints, calling fmt.format("{:!}", i)
on each int will format it in hex if your list was formatted with the x
flag specified and in decimal if nothing was specified.
How does that “abridge” symbol shortener work? In the past I’ve had problems with large variant types (like 50 cases) having large symbols, so I was interested if this would help. It’s doing something with decltype, but I’m still not sure how abridge<T>
can be shorter than T.
The trick is to encode the type in a lambda, something like
template <typename T, auto f = [] { return T{}; }>
using abridge = decltype(f);
Because lambda types don’t follow regular name conventions they end up with much shorter names: https://godbolt.org/z/3bsGPPeG9
Oh, very clever! And then to make it work for non-constructible T you use that id<T>
wrapper.