A few days ago a post from Björn Fahller did the rounds about a compile-time quicksort in C++, using template metaprogramming. It is, as the author concludes, “of limited usefulness, but kind of cool”. Today, I happened to see a follow-up in D, effectively pointing out that D’s standard library
sort()function can be used at compile-time.
[Note: at the time this post was written (September 2016), the version of
std::variantproposed for C++17 permitted reference types at alternatives, although the semantics of assignment were not clear. At the November 2016 meeting the C++ commitee chose to resolve this by forbidding
variant<T&>. This removes the inconsistency with
std::optional<T&>, and thus the main point I was trying to make in this post. Nonetheless, I’d still like to see
optional<T&>and I hope we can come to some consensus about the expected assignment semantics at some point in the future.]
I recently stumbled upon this nice blog post by Josh Barczak, comparing the performance of various C++ string tokenisation routines. The crux of it is that by writing low-level C-like code, Josh was able to get better performance than by using Boost or either of the standard library solutions he tried.
subscribe via RSS