|
Boost : |
Subject: Re: [boost] [mpl] multiset
From: Eric Niebler (eniebler_at_[hidden])
Date: 2015-03-14 15:31:58
On 3/12/2015 7:48 PM, Eric Niebler wrote:
> The metafunctions in meta::lazy don't assume their arguments are
> themselves lazy metafunctions, which would make lazy metafunction
> composition difficult. It's really just not the Meta way.
FWIW, I decided this was a legitimate shortcoming of Meta's approach, so
I changed it. Now when you access the nested ::type of a lazy::
computation, it evaluates all nested lazy:: computations[*]. That makes
composition much nicer. For instance:
template<typename N>
struct factorial : eval<
if_c<N::value == 0,
meta::size_t<1>,
lazy::multiplies<N, factorial<lazy::dec<N>>>>>
{};
This behaves differently than MPL[11]. Rather than passing a thunk
representing dec<N> to factorial, lazy::dec<N> gets fully evaluated when
the ::type of the outer lazy::multiplies is accessed. That way,
factorial never gets instantiated with anything that isn't an Integral
Constant. This is much more The Meta Way: types, not thunks.
-- Eric Niebler Boost.org http://www.boost.org
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk