Boost logo

Boost :

Subject: Re: [boost] [GSoC, MPL11] Community probe
From: Agustín K-ballo Bergé (kaballo86_at_[hidden])
Date: 2014-05-01 14:42:13


On 01/05/2014 09:13 a.m., Roland Bock wrote:
> On 2014-05-01 05:10, Agustín K-ballo Bergé wrote:
>> On 30/04/2014 07:34 p.m., Louis Dionne wrote:
>>> As an aside, I think your `all_t` and `any_t` metafunctions could be
>>> more efficient. I'm currently (literally right now) benchmarking
>>> different
>>> implementations for those; I will notify you if there is a better
>>> alternative.
>>
>> I don't know which implementations you are considering (are they
>> publicly available online?), but here is one I found to perform good
>> enough:
>>
>> https://github.com/eggs-cpp/tupleware/blob/draft/include/eggs/tupleware/core.hpp#L187
>>
> Very cool, indeed. The only drawback in my eyes is that the logic of
> using noexcept is a bit convoluted.
>
> That got me thinking, and here's a new version. Even faster (at least on
> my setup, see below), and very easy to read, I think:
>
> // ------------------------------
> #include <type_traits>
>
> template<bool...>
> struct all_helper
> {};
>
> template<bool... Bs>
> using all_t = std::is_same<all_helper<Bs...>, all_helper<(true or Bs)...>>;
> // --------------------------------
>

Awesome results, and the technique is so simple! I'm going to keep this
approach in mind for other possible use cases in the future.

Regards,

-- 
Agustín K-ballo Bergé.-
http://talesofcpp.fusionfenix.com

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