Boost logo

Boost Users :

From: David Abrahams (dave_at_[hidden])
Date: 2006-11-02 13:12:40


"Arkadiy Vertleyb" <vertleyb_at_[hidden]> writes:

> "Terry G" <tjgolubi_at_[hidden]> wrote
>
>> I've just finished reading C++ Template Metaprogramming again.
>> I just don't get it.
>
> Should probably not be your first book on template metaprogramming.

Really? We designed the book to serve as a complete introduction.

> Really, it's just like trying to learn STL without any idea what a
> template is.

It's not as though the book starts out assuming you know what a
metafunction is. What introductory material do you think we missed
and should have covered?

>> Why would someone use a type container?
>
> For example, one could implement a generic tuple class (although I don't
> think boost::tuple uses this approach, but probably fusion does?). Also see
> below...

Of course, that begs the question of why someone would want a tuple.

>> I'd really like a reference to an MPL primer or some case studies.
>
> IMO, you should really start with template metaprogramming itself, and then
> move to MPL. Try Alexandrescu's "Modern C++ design" -- it also contains a
> lot of examples why you would want to use a typelist.

As great a book as "Modern C++ Design" is, it really surprises me to
see it recommended as an introduction to template metaprogramming over
"C++ Template Metaprogramming." MC++D is not about specifically TMP,
and doesn't even attempt to describe what TMP is. It does contain
numerous examples of basic TMP applied to traditional OO design
patterns, which I think is the real point of that book, and IMO makes
MC++D an ideal follow-on to C++TMP.

In C++TMP we tried hard to both

  * define and clarify the basic concepts of TMP and

  * shield the reader from messy, low-level C++ details by using the
    MPL instead of the raw templates employed by MC++D.

> Once you have a basic understanding of template metaprogramming, get
> back to the MPL book -- it's worth it.

Although we do spend considerable breath outlining the Boost
facilities in "C++ Template Metaprogramming" (and despite the spelling
of certain URLs ;-) ), we hope it won't be viewed as "the MPL book."
The whole point was to treat TMP in a way that exposed its general
principles and capabilities, without getting tied up in details of any
particular technology, be it MPL, Loki, or raw C++ templates.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net