No Moves, In-Place Construction: Perfect Forwarding vs. Variadic Templates

In a small code snippet we will extend the post from the NetworkBuffer that we used in our previous article with lambdas and views. We will demonstrate the difference between variadic templates and perfect forwarding vs perfect forwarding. You can find the cpp file in the src-code of the blog repo. The Packet & Buffer - Code In the NetworkPacket we have kept only two member variables for simplicity. Then we make the move ctor and move assignment operator custom so we can see when they are called. ...

March 25, 2026 · 3 min · 557 words

The 'T&&' Trap: Forwarding References in Templated Classes

In this article we will see shortly the trap of forwarding references for a member function of a class that is already templated. Let’s start with a practical and simple example of designing our own stack and get to the topic. Below we design a simple stack using a vector. We just need functions of empty ,top, pop and push. As always, you can also find the code example in the src-code from the repo. ...

March 15, 2026 · 3 min · 543 words

0% Loops vs 100% Lambdas, TMP and Views: Maximal Inlining

On this article, we can see in a mini real-world example how we can get rid of imperative and manual loops that are not at all descriptive, they are difficult to read and maintain, do not help the compiler to inline them and hence, they lack of performance. We will progress with refactoring one step at a time, starting with refactoring using lambdas, then we can advance a bit and expose the lambdas from a custom template function, which handles the internal iteration - a pattern that mimics the logic of modern libraries (and imititates the views implementation) - and finally we will run the code with C++20 and use modern views directly. ...

March 5, 2026 · 7 min · 1456 words

Avoid the RAM Latency: Keeping the Cache Hot and on Linear Access is the Ultimate C++ Optimization

In this benchmark, we explore the importance of keeping data within the CPU cache to avoid expensive retrieval from RAM. By simply ensuring linear data access and accessing by blocks that fit in L1 and L2, we can achieve massive performance gains without changing the underlying algorithm.

February 24, 2026 · 13 min · 2761 words

The Most Dangerous Pattern in C++: Why `const T&` Is Breaking Your Code

const T& binds to everything but it is dangerous

January 7, 2026 · 5 min · 871 words

Advanced Template Metaprogramming: Implementing Hardware Constraints with C++20 Concepts

Templates complilation generate code at compile time, before the program is executed (compile-time vs run-time). Every different instantiation produces a separate function at compile time. This way we avoid writing duplication of the code. Also, we can avoid mistakes even on compilation time when we static assert them. As the name suggests, this checks takes place statically - on compilation. Like this, we avoid mistakes that might appear during runtime, when we should not instantiate a function of a specific type. Static-asserts was already introduced in C++11, though the we have some important imporvements in C++17 like CTAD and concepts or requires in C++20. ...

November 11, 2025 · 4 min · 739 words