• Compile-time Bounds Checking in Flux

    When using bounds checked interfaces, there are often situations during optimisation where the compiler is able to statically prove that a bounds check will always pass, allowing it to omit the checking code entirely. The simplest example would be something like so:

  • Parameter Passing in Flux versus Ranges

    Regular readers of this irregular blog will know that I’m a huge fan of C++20 Ranges and the ‘collection-orientated’ style of code that they allow. For the last few months, I’ve been working on a new C++20 library called Flux, which aims to provide many of the same facilities as Ranges as well as offering improved safety, ease-of-use, and in some cases better runtime efficiency.

  • Experimenting with Modules in Flux

    TL;DR: Flux, my C++20 sequence-orientated programming library, now has experimental support for being used as a module. Provided you’re using a recent compiler and don’t mind a few rough edges, you can say import flux and get going.

  • Ranges and Forwarding References

    Arthur O’Dwyer recently blogged about “universal references” vs “forwarding references”, where he puts the case that T&& (where T is a deduced template parameter) should be properly called a “forwarding reference” rather than the original term (coined by Scott Meyers), “universal reference”.

  • Numeric Range Algorithms for C++20

    TL;DR: I’ve written C++20 range-based versions of the algorithms in the <numeric> header, and you can get them here

  • Rvalue Ranges and Views in C++20

    Back in the mists of time, when the world was a more normal place (well, September last year) I gave a talk at CppCon entitled “An Overview of Standard Ranges”. Unfortunately I ran a little long and didn’t have time to take questions on video at the end, but since my talk was right before lunch I ended up having a informal Q&A session in the room afterwards for about 45 minutes. One of the questions that came up a few times was about the relationship between rvalue ranges and views, and what you can do with them. At the time it occurred to me that it might be useful to write a blog post clarifying things, but since the nomenclature and mechanisms were still somewhat in flux at the time I decided I’d wait until C++20 was finalised.

  • Opt-in UFCS with "using class"

    Sadly, I’ve never had a chance to read Bjarne Stoustrup’s “Design and Evolution of C++”. I suspect I’d find it fascinating, and that it would probably answer many questions I have in my mind about why things in C++ are the way they are today. Unfortunately the book seems to be in short supply (I assume it’s out of print), and the prices for new copies on Amazon are rather on the steep side.

  • Beware of copies with std::initializer_list!

    Pop quiz: what does the following C++ program do?

  • A more useful compile-time quicksort in C++17

    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.

  • The Case for Optional References

    [Note: at the time this post was written (September 2016), the version of std::variant proposed 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.]

  • A Quicker Study on Tokenising

    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