Boost logo

Boost :

Subject: Re: [boost] [mpl] multiset
From: Louis Dionne (ldionne.2_at_[hidden])
Date: 2015-03-12 20:05:40

Eric Niebler <eniebler <at>> writes:

> [...]
> using factorial_ = lambda_rec<_a,
> lazy::if_<lazy::greater<_a, meta::size_t<0>>,
> lazy::multiplies<_a, lazy::apply<_self, lazy::dec<_a>>>,
> meta::size_t<1>>>;
> template<std::size_t N>
> using factorial = apply<factorial_, meta::size_t<N>>;
> Metafunctions? We don't need no stinkin' metafunctions!

FWIW, here's how you can implement a factorial with lazy
metafunctions, here done with MPL11:

    template <typename N>
    struct fact
        : if_c<N::value == 0,
            mult<N, fact<pred<N>>>
     { };

Lambda expressions are a nice hammer, but a factorial metafunction
is seemingly not a nail.


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