|
Boost : |
Subject: Re: [boost] [review][mp11] Formal review of Mp11
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2017-07-15 12:57:28
On 07/15/17 15:47, Peter Dimov via Boost wrote:
> Vinnie Falco wrote:
>
>> * The documentation states: "mp_if_c<true, T, Eâ¦> is an alias for T.
>> mp_if_c<false, T, E> is an alias for E. Otherwise, the result is a
>> substitution failure."
>>
>> Should that read "mp_if_c<false, T, E...>"? If not, why?
>
> No.
>
> The idea here is that mp_if_c can be used in two ways. One is
> mp_if_c<Cond, T, E>, which gives either T or E depending on Cond. The
> other is mp_if_c<Cond, T>, which is the same as std::enable_if_t<Cond,
> T> - gives T when Cond, otherwise a substitution failure.
>
> So
>
> mp_if_c<true, T> is T
> mp_if_c<true, T, E> is T
> mp_if_c<false, T, E> is E
>
> Aliases can't be specialized, so it's not possible to implement just the
> above, which is why it takes a parameter pack for E... and does
>
> mp_if_c<true, T, E...> is T
> mp_if_c<false, T, E> is E
>
> which for the three cases we're interested in gives the results we need.
Why not separate the two use case into two primitives? We usually want
one or the other and different tools would make sense, at least for
documenting purpose.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk