How do you static_assert the values in a parameter pack of a variadic template?
<p>I'm creating a variadic template.<br>
Let's say I have something like this:</p>

<pre><code>template&lt;typename T, T ... Numbers&gt;
class Sequence final {

    // Unpack parameter pack into a constexpr array
    constexpr static T count = sizeof...(Numbers);        
    constexpr static T numbers[count] = { Numbers... };

    // ...
}
</code></pre>

<p>Instances of this class can be instantiated like:</p>

<pre><code>Sequence&lt;uint32_t, 1, 2, 3, 42, 25&gt; seq;
</code></pre>

<p>I'd like to make sure at compile time using a <code>static_assert</code> that the <code>numbers</code> parameter pack only contains specific numbers. For the sake of this example, let's say I only want to allow <code>0</code> or <code>1</code>.</p>

<p>So I'd like to do something like:</p>

<pre><code>for (size_t i = 0; i &lt; count; i++) {
    static_assert(numbers[i] == 1 || numbers[i] == 0, "Only ones and zeroes are allowed.");
}
</code></pre>

<p>But obviously, <code>static_assert</code> doesn't work with a <code>for</code> loop. I'm pretty sure there must be some sort of syntax for this but I haven't been able to figure it out.</p>

<p>I'd prefer to use something that compiles with a C++11 compiler (or perhaps a C++14 compiler, if it isn't doable in C++11).</p>