title: How do I enable_if a variadic template constructor only if more than n arguments are given?
body: <p>I have a class with the following constructors:</p>
  
  <pre><code>template&lt;typename T&gt;
  class MyClass {
  public:
      MyClass() = default;
      explicit MyClass(T val) : value_1(val) { /* ... */ }
      explicit MyClass(T val, T val2) : value_1(val), value_2(val2) { /* ... */}
  
  private:
      T value_1 = 0;
      T value_2 = 0;
  };
  </code></pre>
  
  <p>I also want to create a constructor that takes an arbitrary number of arguments (all of which can be <code>T</code>'s). The constructor also mustn't shadow the other constructors I already wrote, as the work done is different. I tried around with <code>enable_if</code> a little bit, but am unable to get this to work. Here is what I have so far:</p>
  
  <pre><code>template&lt;typename... TArgs&gt;
  explicit MyClass(TArgs... mArgs, typename std::enable_if&lt;sizeof...(mArgs) &gt;= 3&gt;) { /* ... */ }
  </code></pre>
  
  <p>However, when called like this:</p>
  
  <pre><code>MyClass&lt;double&gt;(2, 3, 4, 5, 6, 7);
  </code></pre>
  
  <p>it yields this error (among others):</p>
  
  <pre><code>error: no matching function for call to 'MyClass&lt;double&gt;::MyClass(int, int, int, int, int, int)'
  </code></pre>
  
  <p>So the compiler probably doesn't even see the constructor. On the other hand if I just leave out the <code>enable_if</code>, it will never call my other, more specialized constructors.</p>
  
  <p>In short, how do I make it so the variadic constructor is called <strong>if and only if</strong> there are three or more arguments given to the constructor?</p>
  
  <p>EDIT:</p>
  
  <p>As proposed in the comments, I have now also tried the following, which also does not work:</p>
  
  <pre><code>template&lt;typename... TArgs&gt;
  explicit MyClass(TArgs... mArgs, typename std::enable_if&lt;sizeof...(mArgs) &gt;= 3&gt;::type) { /* ... */ }
  </code></pre>
  
  <p>as well as</p>
  
  <pre><code>template&lt;typename... TArgs&gt;
  explicit MyClass(TArgs... mArgs, typename std::enable_if&lt;sizeof...(mArgs) &gt;= 3&gt;* = nullptr) { /* ... */ }
  </code></pre>
  
  <p>or any combination of the two.</p>