A Trip Through the CPU Pipeline

When we compile our code from C++ to Assembly, it converts it into a stream of instructions. The CPU then reads this stream of instructions and executes them. But in reality, it’s not as simple as just getting an instruction and executing it. In this tip we’ll look at what...

18 minute read

Compiler Optimisations

There are a variety of optimisations that can be applied to code; ranging from optimising machine code to analysing and processing functions as a whole. This tip will try and briefly cover a few of the interesting / common ones. Overall, there are quite a few optimisations that can be...

12 minute read

Implicit Conversions in C++

Let’s go through all the different types of conversions that are allowed in C++. Implicit conversions make C++ code easy to use and result in terse syntax but can often have unintended effects. While ideally, one probably doesn’t need to think about these conversions all the time, it’s good to...

11 minute read

Cyclomatic Complexity

In this one we’ll delve into the subject of how to evaluate code without getting too much into the syntax or semantics of a particular language. Cyclomatic Complexity This is a measure used to indicate the number of independent code paths through a (let’s say) function. This gives us a...

4 minute read

Cost of RTTI

Polymorphism is a widely used technique that allows for abstracting an interface with different behaviours underneath. The most common way of doing this is using virtual functions and dynamic_cast. While this is a language supported feature, it’s not the only possible implementation of polymorphism. Let’s look at how dynamic_cast works,...

7 minute read

Acceptable Noexcept

In this tip we’ll look at the caveats associated with noexcept. The noexcept Guarantee One common misconception is that noexcept implies that the function will not throw. This is wrong. Decorating a function with the noexcept specifier means that if the function does end up throwing, then it will result...

6 minute read

Guidelines For Initialisation

This is a combination of Herb Sutter’s GotW #1 and Abseil Tip #88. There are about 18 ways to initialise a variable in C++. Especially given C++ 11’s uniform initialisation syntax it’s getting pretty complicated. Use the following guidelines when trying to initialise a local or member variable: Use {}...

3 minute read