I’ve been setting up localisation for an application using a combination of tools: the Boost Locale library and the widely used gettext tools. I’m wanting to work entirely in UTF-8 because it shoul...
Generate UTF-8 dictionaries using gettext
Decimal places in a floating point number
Floating point numbers are a mainstay of programming in areas such as games, graphics, and simulation. On the whole, they are easy and intuitive to use. However, they have certain quirks and issues...
Emit audible warning from a batch script
Windows Batch (*.bat) scripting is archaic and painful, but occasionally useful for quick bits of environment setup. It’s not always obvious to the user when something has gone wrong though as it’s...
How to check that a function is constexpr
I was implementing a number of simple constexpr functions in a recent C++ project. While writing unit tests alongside it, I quickly realised that it would be very helpful to have code which verifie...
C++ constexpr functions
I’ve been very excited to see that Visual Studio 2015 supports the constexpr keyword in C++. It was introduced in the C++11 standard, and is being taken further in upcoming revisions. There are a ...
Using C++ templates for size-based type selection
The standardisation of size-specific integer types in C/C++ is extremely useful for portability. That is, when you use types like uint16_t and int32_t, you know exactly what size of data type you’r...
Pure virtual final functions in C++
Today I ran across an interesting little quirk of C++11. You can declare a pure virtual function which has no implementation and which is final. That means the class can never be instantiated or in...
Order of parameter evaluation in C++
The low-level details of how data gets passed into a function are often overlooked by programmers. We obviously care about passing parameters by value vs. reference and by copy vs. move, but it’s e...
MFC prevents bad_alloc from being thrown
According to the C++ standard, the new operator should throw std::bad_alloc if it fails. This will typically happen if your process has run out of memory. However, this isn’t the case if your progr...
Convert a number to a binary string (and back) in C++
Sometimes it’s useful to output the binary representation of a number in text, i.e. as an ASCII string of 0’s and 1’s. There are also situations where you might want convert back the other way, e.g...