Boost logo

Boost :

From: Joel de Guzman (djowel_at_[hidden])
Date: 2003-01-06 22:19:32


----- Original Message -----
From: "David Abrahams" <dave_at_[hidden]>

> "David B. Held" <dheld_at_[hidden]> writes:
>
> > "David Abrahams" <dave_at_[hidden]> wrote in message
> > news:uk7hitelq.fsf_at_boost-consulting.com...
> >> Yitzhak Sapir <yitzhaks_at_[hidden]> writes:
> >>
> >> > I think storing the text "Hello world!" in a vector
> >> > [...]
> >> > And then using functors to print it such as:
> >> [...]
> >
> > While this is a cute idea, my first impression would be: "Uh...is this
> > really something I could use in my own code?" On the other hand,
> > I seem to use compile-time if more than anything else, even in "user
> > code". I suspect that most people will use mpl::if_ and type traits
> > more than anything else, so I think Dave's original example with
> > is_pointer<> would connect with the most programmers.
>
> I think I agree with you here.

And I disagree. I think the hello world example presented is a
good start to whet the appetite of a would be MPL user. Why?

1) It shows, in simple terms, how compile time structures can be
useful at runtime.

2) An STL programmer will immediately be at home because of the
use of the vector and the for_each.
    
> > On the other hand, I suspect that library authors are more likely to
> > use the type containers and algorithms, so an example illustrating
> > those might be more appropriate for them. So I guess it depends on
> > the intended audience.
>
> I dunno, I use compile-time if_ in my libraries more than anything
> else.

Same here.

> > P.S. Outputting "Hello, world" in a way that generates significantly
> > more code than the run-time version is probably not a good way to
> > endear users to metaprogramming. ;>

Again, I disagree. The C++ hello world generates more code (bringing
in the iostreams in whole) than its C counterpart yet no one complained.

Joel de Guzman
joel_at_[hidden]
http://www.boost-consulting.com


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk