Boost logo

Boost :

From: David B. Held (dheld_at_[hidden])
Date: 2002-08-01 23:43:24

"Ihsan Ali Al Darhi" <iad929_at_[hidden]> wrote in message
> What is the industrial strength of such a library? I mean in what
> I may want or need to use MPL or meta prograamming in general?

Well, unfortunately, I'm not the most qualified person to answer those
questions. Andrei has answered the last question to some extent in
Modern C++ Design, which is probably a must-read for this type of
stuff. For metaprogramming wannabes, the obvious places to start
using MPL and MPL-type facilities include compile-time type switches,
hierarchy generators, and compile-time arithmetic.

An instance of the first would be to specialize a generic class/algorithm
if the actual type matches some criteria, in which you could use mpl::if_.
For an instance of the second, consult MC++D. ;) And off the top of
my head, I seem to recall there are times when a compile-time gcd
computation is useful (for computing alignment and such). A more
advanced usage of MPL can be found in the MPL paper, which
describes the outline of an FSM generator, which is quite cool, IMO.

Getting a little off this topic, I would like to say that I predict the
usefulness of MPL's iterators will not be ultimately judged by the fact
that they work with various compile-time sequences. The STL iterator
is not powerful because it's a cute way to access the contents of a
standard container. It is powerful because it defines an abstract set
of concepts that allow you do wonderful things in a generic way. In
particular, the iterator_adaptors library probably highlights the true
power of the iterator in a most appropriate way. Thus, I would like to
make this rather bold and completely unfounded prediction:

    I predict that MPL's iterators will ultimately be shown to be
    useful because of the genericity of the iterator concept itself.
    This will allow the creation of meta-iterator-adaptors that will
    harness the formal notion of an iterator (and meta-iterator) to
    produce unexpected but useful non-container iterators that will
    seamlessly integrate with existing meta-algorithms.

Unfortunately, I don't have the insight or expertise to produce
examples of such beasts. But eventually, either by accident or intent,
someone more clever than me will attempt such a thing, and thus
decide the success of my prediction.


Boost list run by bdawes at, gregod at, cpdaniel at, john at