I’ve finally had a little time to advance with reading Alexandrescu’s book on Modern C++ design, and I’m absolutely blown away by the sheer awesomeness of its ideas. I highly recommend getting this book!
I would like to show just a little bit of what we can do with template specialization when it comes down to meta programming.
Continue reading Computing the level of indirection for pointer types
This is actually not a typo, I really meant to repeat the first word. Let’s see what template template parameters are..
Continue reading Template template parameters
Both std::cin and std::cout provide a conversion to a void* type, but not to a boolean:
operator void* (); // zero if and only if fail()
What use does a conversion to a boolean have, and which pitfalls does the current implementation save us from?
Continue reading Why do cin and cout have conversion to a void* and not bool?
In this post I will introduce a common problem you are likely to bump into when inheriting from templated base classes.
Continue reading Subclassing templates
C++ provides a mechanism that allows any function to declare exactly which exception types it may throw, and these declarations are actually enforced in runtime. We will review exactly how this mechanism works, and why it is usually left unused.
Continue reading Exception specifications
Suppose you have an array of integers and a comparator function object. Your mission, should you choose to accept it, is to sort the array in a reversed order.. Using only a single line of code.
Continue reading One-line rsort of an integer array
This post continues and explains the previous post.
In the example from the previous post, our base class has invoked a virtual function during the construction of the object, expecting that the correct function would be called. Why was that an error, you ask ?
Continue reading Virtual dispatching within a constructor/destructor
Find below a post on the topic of file signatures, also known as Magic Numbers. The provided code snippet contains an error for the reader to discover and point out.
Continue reading Checking file signature
I’ll assume you are already familiar with the concept of namespaces, and the using keyword. So let me try and introduce some of the less common features of the namespace mechanism.
Continue reading Everything about namespaces
This article will discuss references to temporary objects – a mechanism with a few subtleties.
Continue reading Reference to temporary