17

Can anyone recommend any good resources for learning C++ Templates?

Many thanks.

Dynite
  • 2,313
  • 5
  • 30
  • 38

7 Answers7

12

I recomned that you get C++ Templates - The Complete Guide it's an excellent resource and reference.

Torbjörn Gyllebring
  • 17,928
  • 2
  • 29
  • 22
12

I've found cplusplus.com to be helpful on numerous occasions. Looks like they've got a pretty good intro to templates.

If its an actual book you're looking for, Effective C++ is a classic with a great section on templates.

Lazer
  • 90,700
  • 113
  • 281
  • 364
Gordon Wilson
  • 26,244
  • 11
  • 57
  • 60
5

This is a more advanced, but very useful, book on templates and template use.

Modern C++ Design

workmad3
  • 25,101
  • 4
  • 35
  • 56
  • To understand this book you'll need to understand how templates work first. It's an interesting book but not for the faint of heart, nor for beginners - which the OP is I think, if he needs to ask this question. – Roel Sep 30 '08 at 09:17
  • Only a beginner to Templates, not C++. – Dynite Sep 30 '08 at 09:19
  • As long as the basics are there, you can learn most of the important aspects about templates from their use in this book. Agreed that it is a huge learning curve to do it this way though :) – workmad3 Sep 30 '08 at 09:21
  • Yeah beginner of templates I meant. For a beginner of C++ this book is definitely way out of league. – Roel Sep 30 '08 at 10:13
4

Bruce Eckel's Thinking in C++ is how I learned about templates. The first volume has an introductory chapter and the second volume has an in-depth chapter on templates.

There's Bjarne Stroustrop's The C++ Programming Language which has a good chapter on them. And The C++ Standard Library: A Tutorial and Reference which is about the standard library, but would definitely help you get a better understanding of how templates could be used in the real world. .

Firas Assaad
  • 25,006
  • 16
  • 61
  • 78
2

Be sure to differentiate between generic programming and template metaprogramming (which is more like another paradigm)

Generic programming can be learnt from the C++ bible, but you can just as well take a look at the java generics etc...

one about metaprogramming: Josuttis' book C++ Templates: The Complete Guide

xtofl
  • 40,723
  • 12
  • 105
  • 192
2

The 2 volumes of 'Thinking in C++' go over the basics of templates. They can either be bought in print, or downloaded for free (and legal) use here.

workmad3
  • 25,101
  • 4
  • 35
  • 56
0

"The C++ Programming language" by Bjarne Stroustrop

TG.
  • 1,035
  • 3
  • 15
  • 23