Skip to main content
gamedev.net
🔒 Locked

Templates Tutorials

Started by bkt Apr 4, 2005 at 10:21 PM 11 replies 2.1k views
Original Post
bkt
bkt
I'm looking for a good tutorial on the use of templates; as of right now I've been using them for some very basic pattern implementions and nothing else. Internet tutorials (free ones!) would definately be great, but as would books. I know I saw a book somewhere on here that seemed like it would be good, but I want to know everyone else's opinion on the matter. Its one of my weak areas; I want to strengthen myself up!
-John "bKT" Bellone [homepage] [[email=j.bellone@flipsidesoftware.com]email[/email]]
antareus
antareus
Modern C++ Design - *the* book on generic programming...truly revolutionary
C++ Templates - the nitty-gritty details of the template system
Imperfect C++ - useful applications of templates

As for Internet tutorials, I don't know of many.
--God has paid us the intolerable compliment of loving us, in the deepest, most tragic, most inexorable sense.- C.S. Lewis
bkt
bkt
Thanks a lot man, I'll definately be looking into buying those books. I think I need something to spice up my programming, its been lacking ever since these beginner's introduction classes I'm taking at community college. I think I'm going to die learning how to "properly use an if statement."

Halfway through the semester and we haven't even touched loops yet. Ugh.
-John "bKT" Bellone [homepage] [[email=j.bellone@flipsidesoftware.com]email[/email]]
antareus
antareus
The first two books are pretty hardcore. And by hardcore I mean it took about a year to really grasp what was going on in MC++D. If you enjoy a challenge, I recommend it. The third book is a lot more practical and easier reading at times.
--God has paid us the intolerable compliment of loving us, in the deepest, most tragic, most inexorable sense.- C.S. Lewis
aaroncox1234
aaroncox1234
Not sure if it goes into enough detail for you, but Thinking in C++ has a chapter on templates. It's free to download, just do a search.
-------------------------------See my tutorial site: Click here
gumpy
gumpy
Quote:
Original post by aaroncox1234
Not sure if it goes into enough detail for you, but Thinking in C++ has a chapter on templates. It's free to download, just do a search.

thinking in c++ vol. 2 discusses templates and more.
This space for rent.
bkt
bkt
I definately enjoy challenges; I'm going to pick that book up. Thanks for everyone's input!
-John "bKT" Bellone [homepage] [[email=j.bellone@flipsidesoftware.com]email[/email]]
nuvem
nuvem
Another great way to learn is to take apart a random boost library and figure out how it works. It will blow your mind.
Qw3r7yU10p!
Qw3r7yU10p!
Angelika Langer's website has lots of good articles including this one on Expression Templates.

Also Todd Veldhuizen's Template Metaprograms and ExpressionTemplates.

Also this article about using the boost metaprogramming library to create a dimensional analysis library for checking, at compile time, to make sure that for example, a variable representing acceleration really is made up of a distance variable divided twice by time variables.
bkt
bkt
Quote:
Original post by nuvem
Another great way to learn is to take apart a random boost library and figure out how it works. It will blow your mind.


That was actually one of my plans, I haven't gotten around to it yet though.
-John "bKT" Bellone [homepage] [[email=j.bellone@flipsidesoftware.com]email[/email]]
Qw3r7yU10p!
Qw3r7yU10p!
Quote:
Original post by antareus
Modern C++ Design - *the* book on generic programming...truly revolutionary
C++ Templates - the nitty-gritty details of the template system
Imperfect C++ - useful applications of templates

As for Internet tutorials, I don't know of many.


See sample chapters for MC++D Ch 1: Policy based design Ch 7: Smart pointers

C++ Templates sample chapters
jdhardy
jdhardy
Quote:
Original post by petewood
Also this article about using the boost metaprogramming library to create a dimensional analysis library for checking, at compile time, to make sure that for example, a variable representing acceleration really is made up of a distance variable divided twice by time variables.
That comes from Abrahams' and Gurtovoy's "C++ Template Metaprogramming" (aka "The MPL Book"), which is an excellent book I can't recommend enough. I suggest reading "Modern C++ Design" first to get an idea of what the MPL book is all about, which is formalizing the ideas presented in "Modern C++ Design".

Quote:
Original post by nuvem
Another great way to learn is to take apart a random boost library and figure out how it works. It will blow your mind.
Especially Spirit. Spirit is the holy grail of template metaprogramming.

However, I find that much of boost is obscured the preprocessor code (cf. the Boost.Preprocessor library) that is required to overcome limitations of the template engine. Learning the PP library is pretty much a prereq to understanding boost code.

The combined power of Boost.MPL and Boost.PP is nothing short of amazing (although I'm sure Lispies are laughing at us...)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.