Slashdot Mirror


C++ Templates: The Complete Guide

nellardo writes "The book C++ Templates: The Complete Guide, by Vandevoorde and Josuttis, Addison-Wesley 2003, is an authoritative treatment of exactly what it claims: the template mechanism of C++. If you are a C++ programmer, you should have this book on your shelf. If you aren't a C++ programmer, move along -- this book is highly specific to C++, and won't be much help in understanding the template mechanisms of other languages. Of course, if you aren't a C++ programmer, you probably wouldn't even give this book a second glance in the first place." Read on for the rest of Brook's review. C++ Templates: The Complete Guide author David Vandevoorde & Nicolai M. Josuttis pages 528 publisher Addison Wesley rating 10 for C++ programmers, 0 for anyone else. reviewer Brook Conner ISBN 0201734842 summary A thorough, exhaustively complete treatment of a complex subject. An essential reference for C++ programmers and a lengthy and boring book for anyone else.

The C++ programming language is widely regarded as a good systems programming language, albeit a complex one fraught with low-level details and issues (though arguably this is what makes it good for certain kinds of systems programming). For perhaps a decade now, C++ has had a template mechanism - in programming language circles, it might more properly be called a form of parametric polymorphism. The template mechanism, like many other forms of parametric polymorphism, is potentially extremely powerful, but the complexity of C++ makes it tough to thoroughly master. That's where this book comes in.

Most likely, an experienced C++ programmer has at least used templates. If nothing else, use of the Standard Template Library (or STL) requires at least knowledge of how to use templates. If you use C++ enough to care about templates, you probably know what they are, at least roughly, and if you don't, this isn't the book from which to learn about them. It very clearly requires (and explicitly states in the introduction) that you need to know C++ before making effective use of the book.

Designing template classes, however, is another kettle of fish, and if you're in a position where you're building template classes for someone else to use, you probably need this book. Unless, like the book's authors, you moderate comp.lang.c++.moderated. If you are such a super C++ guru, you may still find this book useful - it is a truly stupendous catalog of the capabilities and subtleties of C++ templates. If nothing else, you'll find examples for well nigh every use to which you are likely to put C++ templates.

The book's strengths, then, are its authoritative and exhaustive detail. On the downside, its examples are dry and flavorless. Perhaps this is intentional, as a way to suggest how some feature can be used in a variety of situations. I prefer a combination of specific, concrete examples, followed by a generic example. The specifics motivate the need for a capability, while the generic showcases the broad, interrelated aspects of the capability. The authors didn't follow that approach. I would suspect this comes in part from their mutual roles in C++ standards bodies - a specific example could be seen as too limiting, and so were left out.

Another drawback, to my thinking, is its resolute focus on C++ to the exclusion of all other languages. Don't get me wrong - I read the title, and it's a C++ book, so I don't expect it to teach me Scheme, much less Haskell. However, I think the complexities of C++ templates might have been easier to tackle and understand with at least pointers to other ways it could have been (and has been) done. If nothing else, citations of alternative approaches would be a useful source for the motivated reader. As it is, it doesn't even deal with differences between C++ implementations - it doesn't even list GCC in the index.

All in all, though, C++ Templates: The Complete Guide is exactly what it claims to be. It's an in-depth treatment of C++ templates and how they work. It isn't a cookbook for practical applications, nor is it a guide to further in-depth exploration of parametric polymorphism. But it is definitely a handy reference for the working C++ programmer to have on her shelf. If you're a working C++ programmer, I'd recommend it. If you aren't, you might want to pass on this one.

You can purchase C++ Templates: The Complete Guide from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

2 of 371 comments (clear)

  1. Congressman Boucher sells out! +1, Patriotic by Anonymous Coward · · Score: -1, Offtopic
    from Slate:

    Kurd Sellout Watch, Day 2
    Tracking a betrayal as it unfolds.
    By Timothy Noah
    Posted Tuesday, March 4, 2003, at 2:50 PM PT

    As Chatterbox noted yesterday ("How Screwed Are the Kurds?"), the United States is hardly the first country to stick it to the Kurds. But this does appear to be the first time that the sellout can be tracked, via the Web, in something approximating real time. Chatterbox will therefore expand his previous Kurd dispatch into a Kurd Sellout Watch.

    In today's installment, we learn, via a report from Patrick Cockburn in the Independent, that Kurdish leader Hoshyar Zebari says the Kurds will fire at Turkish soldiers coming through the Kurds' enclave in northern Iraq even if those soldiers are part of a U.S. coalition. The Kurds will hold their fire only if the Turks are under U.S. command.

    The State Department remains no more forthcoming about what roaming privileges it has promised the Turkish army if the Turks allow U.S. troops to be based there. Here's spokesman Richard Boucher at the March 3 press briefing:

    Q: You said it was widely known that there was a plan for Turkish troops to enter northern Iraq. You said nothing hasâ"we have nothing new on that. Does that mean that such a plan still exists and could go ahead?

    A: Are you asking about Turkish military matters? One, I don't talk about military matters, and two, I don't talk about foreign governments' military matters.


    Looks like your "digital rights golden boy" is doing his part to make sure that the kurds don't have any leadership in postwar iraq. hell, he's leaving the door open for turkey to take over the kurdish lands! whenever GW says, "saddam gassed his own people!" he is talking about the kurds, yet it looks like the US is gonna let the turks rape them as well.

    he supports "fair use" (aka piracy) of DVDs, yet he doesn't support a group who has been loyal to the US for years! what a scumbag, let's send him a letter immediately!
  2. Her shelf by Anonymous Coward · · Score: -1, Offtopic

    "But it is definitely a handy reference for the working C++ programmer to have on her shelf." aaahahahahahaha.... her shelf... i mean, you know.... or, at least, you programmers know.... i know it's not PC, but, well.... aaaaaaaaahahahahahahaha