Jump to ratings and reviews
Rate this book

C++ Templates: The Complete Guide

Rate this book
Templates are among the most powerful features of C++, but they remain misunderstood and underutilized, even as the C++ language and development community have advanced. In C++ Templates, Second Edition, three pioneering C++ experts show why, when, and how to use modern templates to build software that’s cleaner, faster, more efficient, and easier to maintain.

 

Now extensively updated for the C++11, C++14, and C++17 standards, this new edition presents state-of-the-art techniques for a wider spectrum of applications. The authors provide authoritative explanations of all new language features that either improve templates or interact with them, including variadic templates, generic lambdas, class template argument deduction, compile-time if, forwarding references, and user-defined literals. They also deeply delve into fundamental language concepts (like value categories) and fully cover all standard type traits.

 

The book starts with an insightful tutorial on basic concepts and relevant language features. The remainder of the book serves as a comprehensive reference, focusing first on language details and then on coding techniques, advanced applications, and sophisticated idioms. Throughout, examples clearly illustrate abstract concepts and demonstrate best practices for exploiting all that C++ templates can do.


Understand exactly how templates behave, and avoid common pitfalls Use templates to write more efficient, flexible, and maintainable software Master today’s most effective idioms and techniques Reuse source code without compromising performance or safety Benefit from utilities for generic programming in the C++ Standard Library Preview the upcoming concepts feature The companion website, tmplbook.com, contains sample code and additional updates.

Kindle Edition

First published November 12, 2002

78 people are currently reading
313 people want to read

About the author

David Vandevoorde

6 books7 followers

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
95 (43%)
4 stars
88 (40%)
3 stars
31 (14%)
2 stars
5 (2%)
1 star
1 (<1%)
Displaying 1 - 12 of 12 reviews
Profile Image for Gavin Ridley.
16 reviews1 follower
January 22, 2020
Super dry, but great to take your C++ programming skills to the next level. I’ve always been boggled looking at implementations of stuff in the standard library and certain pieces of OpenFOAM code, and this book cleared up my confusion and gently introduced the patterns commonly used for template programming. Now I know what’s going on seeing stuff like enable_if, typename=void, etc. Worth the read, overall!
124 reviews15 followers
January 29, 2008
Decent way to learn C++ templates if you must do so. Prepare to alternately have your mind blown and weep at the hoops C++ makes you jump through to do such conceptually simple things.

If it's the concepts you're after rather than specifically C++, I would highly recommend using another language. If it's parametric polymorphism you want, try OCaml or Standard ML (or use a dynamically typed language where this is unnecessary). If it's metaprogramming you're after, look at any Lisp dialect or MetaOCaml.
30 reviews
March 16, 2017
Old but gold.
Something is outdated, but most of the book is still usefull and can explain a lot of "template magic".
4 reviews1 follower
April 28, 2018
Not only the best C++ Template book but also one of the best modern C++ book.
14 reviews4 followers
May 7, 2007
I'm halfway through this book. I'm not in love with the way its written -- it's dense and poorly organized. The information doesn't seem to be delivered in the linear fashion I want for a book thats meant to be read through and not just referenced. The preface even goes so far as to say "Read section 1, then section 3, then look back at section 2 and then read section 4 if you want".

However --- The information itself is gold. This book really unlocks the mystery of how, when and why to use a template instead of traditional inheritance/virtual function. For that I am indebted to it.
Profile Image for Alasdair Craig.
288 reviews14 followers
May 24, 2017
Published in 2002, this is a thorough coverage of everything to do with C++ templates, as it was with the C++ standard at the time. I wish I had read it years ago. It covers how templates work at various levels of complexities and how to use them. However, the C++11 specification is now standard, and a lot has since changed. I'm very pleased to read that the authors are planning a revised edition.
Profile Image for Erk1024.
29 reviews
June 26, 2011
Very clear explanations. It's great as an e-book, so you can read parts of it while compiling. '-)
Displaying 1 - 12 of 12 reviews

Can't find what you're looking for?

Get help and learn more about the design.