Boost logo

Boost :

Subject: Re: [boost] [GSoC, MPL11] Community probe
From: Roland Bock (rbock_at_[hidden])
Date: 2014-05-01 08:13:15

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:
> Just drop the `constexpr` since it's not actually needed and it
> confuses GCC. It's a bug according to my reading of
> [expr.unary.noexcept]/3, but I didn't have the time to investigate
> further yet.
> Regard,
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>

struct all_helper

template<bool... Bs>
using all_t = std::is_same<all_helper<Bs...>, all_helper<(true or Bs)...>>;
// --------------------------------

I am going to use that in sqlpp11 for the time being, see

Here are some adhoc measurements, using a static_assert with 65536 true
bool arguments (reduced code is attached):

clang++-3.2 -std=c++11 -stdlib=libc++:
Roland: 0.27s
Agustín: 0.73s

clang++-3.4.1 -std=c++11 -stdlib=libc++:
Roland: 0.30s
Agustín: crashes on my machine

g++-4.8 -std=c++11:
Roland: 0.28s
Agustín: 0.79s

Adding a false at the end (asserting a false value) yields the same numbers.

Thanks and best regards,


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