Skip to Content
Practical C++ Metaprogramming
book

Practical C++ Metaprogramming

by Edouard Alligand, Joel Falcou
September 2016
Intermediate to advanced
35 pages
59m
English
O'Reilly Media, Inc.
Content preview from Practical C++ Metaprogramming

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

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Advanced Metaprogramming in Classic C++

Advanced Metaprogramming in Classic C++

Davide Di Gennaro

Publisher Resources

ISBN: 9781492042778Errata Page