Boost logo

Boost :

Subject: Re: [boost] Interesting variadic template trick
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2013-11-19 09:13:26

On 18/11/2013 05:25, Louis Dionne wrote:
> Hi,
> As some might know, I'm currently working on a reimplementation of the MPL
> for C++11. In doing so, I came across a technique that I did not know of and
> I thought I would share my discovery with the community. If this is already
> well known, please excuse my ignorance.
> The goal is to implement fast compile-time conjunction and disjunction.
> It goes like this:
> template <typename ...T> void allow_expansion(T&&...);
> template <typename ...T>
> struct or_ {
> static constexpr bool value = !noexcept(
> allow_expansion((T::value ? throw : 0)...)
> );
> };

An obvious problem with this is that it doesn't compile if exceptions
are disabled.
And I think being able to use meta-programming without exceptions is an
important property to have.

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