Boost logo

Boost Users :

From: Zeljko Vrba (zvrba_at_[hidden])
Date: 2008-07-20 10:34:09


On Sun, Jul 20, 2008 at 09:38:58AM -0400, David Abrahams wrote:
>
> "C++ Template Metaprogramming" is not intended to be a reference book
> about manipulating typelists at all. Did you start reading from the
> beginning of the book, or did you skip to chapter 3 or so? The
> introduction lays some important conceptual foundations about what
> metaprogramming is all about. Typelists (not even a term we use in the
> book) are merely one means to reaching the many ends of metaprogramming.
>
Yes, I did start reading from the beginning. Actually, I have it with me.
There's "1.6. When Metaprogramming". According to that section, the only thing
that I'd like to take advantage of is static type checking.

Section 2 has been understandable, though a bunch of reference documentation
left me wondering about what all those type classification functions might be
useful for. The "flyswapper" example.. nice and understandable, but not
something that has really motivated *me* because it looks like a case of
invoking a lot of arcane syntax (and I guess it'd have been a lot worse without
MPL) to do premature optimization.

>
> That's a reasonable point of view to take if you don't want to do
> template metaprogramming and just want to be a consumer of its benefits.
>
Well, I *do not know* whether I want to do template metaprogramming in the
sense as in your book. This was the starting point for this whole discussion.
I coded a van-Emde Boas tree via template metaprogramming (simple recursion),
and that has had little to do with types. I have no idea where and if the MPL
could have helped -- most probably not because the code is similar to the
binary number example.

>
> Did you look at the binary number example in the first pages of our
> book? It addresses many of the above questions.
>
Yes, it was a nice and understandable example which, coincidentally, does not
use MPL! So in chapter 1 you begin nice and easy with an understandable
example coded without any MPL machinery, and then you suddenly switch in
chapter 2 to example with type classification.

By the way, how would the binary number example be coded with MPL? Would it be
sensible to do it at all?

>
> Ah. Well, some people think every application programmer should think
> of himself as a library developer. If you're writing code that will be
> re-used by your colleagues, or even by yourself, that code is
> essentially library code.
>
Indeed. "Reused". QT is also reusable, yet it does not use templates heavily.

>
> However, you do have a point: fusion, MPL, and templates in general are
> useful for building flexible, generalized components that can be
> configured for different applications without loss of efficiency. If
> you are building one-off code, you probably don't have much use for them.
>
OK, thanks. Anyway, I admire yours and Joels (and others') efforts, but..
let's declare 1:0 in favor of MPL and close the discussion. I'll steer clear
of MPL/fusion for a while more. Maybe the time has come for me to switch to
Java, JITs are steadily getting better :-)


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