Boost logo

Boost :

From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2002-04-11 18:10:15

Andrei Alexandrescu wrote:
> I don't have access to MPL here, could anyone tell me how I can download
> again?

The latest work-in-progress is in the CVS under 'mpl_v2' branch. The current
snapshot of it is available for download from here -

> I forgot what the convention for Predicate was, but I recall it has a
> template class 'apply' that exposes 'value'. Assuming that that's the
> the following code implements count_if, in a slightly terser manner (it
> relies on first principles only - there's no core infrastructure to
> The code maps to the algorithm like this: for a null typelist, count_if is
> zero; for any other typelist, count_if returns an optional one (if the
> predicate is true for the head) plus the result of count_if, applied to
> tail of the typelist.
> template <class TList, class Predicate> struct count_if;
> template <class Predicate>
> struct count_if<Nulltype, Predicate>
> {
> unsigned long,
> value = 0);
> };
> template <class H, class T, class Predicate>
> struct count_if<typelist<H, T>, Predicate>
> {
> unsigned long,
> value = (Predicate::apply<H>::value ? 1 : 0) + count_if<T,
> Predicate>::value);
> };

The above implementation is useless for 'tiny_list' (and any type sequence
we use here at work).


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