Boost logo

Boost :

From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2002-04-14 19:46:31

Andrei Alexandrescu wrote:
> GenScatterHierarchy using mpl's abstractions has 23 lines, defines 3
> new types, and uses 2 artifacts defined elsewhere.

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 >

> Loki defines GenScatterHierarchy in 33 lines, but defines convenience
> inner types Rebind and TList which I believed would be useful but I
> never actually used them; since your implementation doesn't define
> them, I think it is reasonable to remove them for purposes of
> comparison.
> 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).


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