2 posts tagged with "Utility"

  • 28 Mar 2022/ C++

    A utility class for multi-dimensional operator[]

    Sometimes you have data-structures that are multi-dimensional in nature. A classic example might be a matrix or a cube. Alas, there’s no built-in way in the language to deal with multi dimensional array-like access. In this blog post we’re going to develop a little utility class that you can use for exactly that.

  • 03 Oct 2021/ C++

    Using enum classes as bitmasks

    This is just a quick tip on making enum classes a little bit cooler in C++. Consider the following code: enum class MyBitField: uint16_t { eFoo = 1 << 1, eBar = 1 << 2, eBaz = 1 << 3, //... and so on } //Fails to compile! auto fooAndBar1 = MyBitField::eFoo | MyBitField::eBar; //Compiles, but contains *a lot* of noise. auto fooAndBar2 = static_cast<uint16_t>(MyBitField::eFoo)…

All tags