Boost logo

Boost :

From: Paul Mensonides (pmenso57_at_[hidden])
Date: 2003-01-11 22:03:18


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

...

> I mean that if a metafunction is a template instead of a type you
> can't treat it polymorphically with other things, e.g. you can't put
> it in a type sequence.

Yes, you can with the appropriate binders. That is what I meant.

> > struct metafunction {
> > template<class T> struct actual_metafunction {
> > // ...
> > };
> > };
> >
> > vs.
> >
> > template<class T> struct metafunction {
> > // ...
> > };
>
> mpl::lambda handles the transformation from the latter to the former.

Yeah, I retract that statement. ;) It is easy to map them back and forth.

> > I'm not saying the convention is bad, just that it has its own set of
> > associated problems.
> >
> >> Other than that, the final interface you show is one that's acheivable
> >> without TTP at all.
> >
> > Yes, you can do it without TTP, but it isn't as clean. (I only had a
rough
> > idea in my head when I made the remark.) You pay a price for the
> > abstraction that you mention by "metafunction polymorphism."
>
> Hmm?

Code clarity. As abstraction goes up, clarity goes down.

> > Altogether, I'm quite pleased with the mechanism, as I find the linear
> > typelist implementation "neat," and I've never seen anything like that
> > implementation.
>
> libs/python/test/if_else.cpp might be of interest to you.

I'll take a look.

> > The template classes "fold_left" and "fold_right" are not
> > even metafunctions in any normal sense. I wouldn't know what to call
them!
>
> They're interesting to a point, but inflexible. Any given usage is
> restricted to working on sequences of a particular length.

Yes, however, the intended purpose is as an inline definition, not as a
sequence type, and it doesn't require the code replication necessary to
support something like "mpl::vector". I'm not saying that it's "super
great" overall. I'm merely saying that it amuses me, and I like it. ;)

Paul Mensonides


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