Boost logo

Boost :

From: Andrei Alexandrescu (andrewalex_at_[hidden])
Date: 2002-04-14 20:55:18


"Aleksey Gurtovoy" <agurtovoy_at_[hidden]> wrote in message
news:a9d7rv$t7o$1_at_main.gmane.org...
> How about this one:
>
> template <class L, class R>
> struct InheritTwo : public L, public R
> {
> };
>
> template< typename Sequence, typename F >
> struct GenScatterHierarchy
> : mpl::fold< Sequence, mpl::none, InheritTwo< mpl::apply<F,_1>,
_2 >
> {
> };

The versions of GenScatterHierarchy and count_if that you posted
lately look better indeed. They do rely on quite some mpl artifacts -
much more than I find palatable for what they do -, but I guess
there's no reason to agonize over that.

> > This being said, an implementation of GenScatterHierarchy that
works
> > only for dot-typelists and relies on nothing but C++ itself, has
20
> > lines, defines 1 new type, and doesn't use but the typelist
itself.
>
> FWIW, the MPL's version above is 9 lines long. Much more
importantly, it's
> something that is explainable to a non-expert in 5 minutes. (IMO
Loki's
> version is not).

(In the meantime I realized I could have reduced the length of
GenScatterHierarchy by eliminating the unnecessary LeftBase and
RightBase convenience typedefs. But oh well.)

I believe we reduced irreductible viewpoints about the ease of
explanation of the two idioms, so I won't insist on it anymore. The
truth is simple: we are both right. At least because for people like
you, one version is more appealing, and for people like me, the other
is.

Andrei


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