Boost logo

Boost :

Subject: Re: [boost] Interesting variadic template trick
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2013-11-18 01:54:31


On Mon, Nov 18, 2013 at 10:18 AM, Steven Watanabe <watanabesj_at_[hidden]> wrote:
> AMDG
>
> On 11/17/2013 09:55 PM, Andrey Semashev wrote:
>>
>>> template <typename ...T>
>>> struct or_ {
>>> static constexpr bool value = !all_pointers(
>>> ((typename std::conditional<T::value, int, void*>::type)0)...
>>> );
>>> };
>>>
>>> template <>
>>> struct or_<> {
>>> static constexpr bool value = false;
>>> };
>>
>>
>> It requires N instantiations of std::conditional, doesn't it? In that
>> case is it actually faster than the naive recursive instantiation of
>> or_?
>>
>
> No it doesn't. It requires exactly two
> instantiations of std::conditional for
> all uses of or_.

You mean the compiler can optimize multiple instantiations for
different T::value values to just unique ones?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk