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

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