Chapter 1. Introduction
If you grabbed this report, it means that you have at least curiosity about C++ metaprogramming, a topic that often generates outright rejection.
Before we talk about template metaprogramming, let’s ask ourselves a question: why do we violently reject some techniques, even before studying them?
There are, of course, many valid reasons to reject something new, because, let’s be frank, sometimes concepts are just plain nonsense or totally irrelevant to the task at hand.
However, there is also a lot to be said about managing your own psychology when accepting novelty, and recognizing our own mental barriers is the best way to prevent them from growing.
The purpose of this report is to demonstrate that understanding C++ metaprogramming will make you a better C++ programmer, as well as a better software engineer in general.
A Misunderstood Technique
Like every technique, we can overuse and misunderstand metaprogramming. The most common reproaches are that it makes code more difficult to read and understand and that it has no real benefit.
As you progress along the path of software engineering, the techniques you learn are more and more advanced. You could opt to rely solely on simple techniques and solve complex problems via a composition of these techniques, but you will be missing an opportunity to be more concise, more productive, and sometimes more efficient.
Imagine that you are given an array and that you need to fill it with increasing integers. You ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access