title: Specializing class with SFINAE if a parameter pack is needed
body: <p>As I got a perfect answer for the question:
  <a href="https://stackoverflow.com/questions/37280531/specializing-class-with-sfinae">Specializing class with SFINAE</a></p>
  
  <p>For completeness I insert the correct solution as example here again:</p>
  
  <pre><code>class AA { public: using TRAIT = int; };
  class BB { public: using TRAIT = float; };
  
  template &lt; typename T, typename UNUSED = void&gt; class X;
  
  template &lt; typename T &gt;
  class X&lt;T, typename std::enable_if&lt; std::is_same&lt; int, typename T::TRAIT&gt;::value, void &gt;::type&gt;
  {
      public: 
          X() { std::cout &lt;&lt; "First" &lt;&lt; std::endl; }
  };
  
  template &lt; typename T &gt; 
  class X&lt;T, typename std::enable_if&lt; !std::is_same&lt; int, typename T::TRAIT&gt;::value, void &gt;::type&gt;
  {   
      public:
          X() { std::cout &lt;&lt; "Second" &lt;&lt; std::endl; }
  };
  
  int main()
  {
       X&lt;AA&gt; a;
       X&lt;BB&gt; b;
  }
  </code></pre>
  
  <p>But if I have to use a parameter pack for further use, I see no chance to write the things down like:</p>
  
  <pre><code>template &lt; typename T, typename ...S, typename UNUSED = void&gt; class X;
  </code></pre>
  
  <blockquote>
    <p>error: parameter pack 'S' must be at the end of the template parameter list</p>
  </blockquote>
  
  <p>Having the definition in a different order like</p>
  
  <pre><code>template &lt; typename T, typename UNUSED = void, typename ...S&gt; class X;
  </code></pre>
  
  <p>ends up in problems if the first additional type is in use.</p>
  
  <p>OK, what I describe is a technical solution which I can't find actually. Maybe there is a different one. What is my underlying problem: I need 2 different constructors for the class which call different base class constructors. But because both constructors have the same set of parameters I see no chance to specialize the constructors itself.</p>
  
  <p>If specialize constructors can work, it can be something like that:</p>
  
  <pre><code>template &lt; typename T&gt;
  class Y
  {
      public:
          template &lt;typename U = T, typename V= typename std::enable_if&lt; std::is_same&lt; int, typename U::TRAIT&gt;::value, int &gt;::type&gt;
              Y( const V* =nullptr) { std::cout &lt;&lt; "First" &lt;&lt; std::endl; }
  
          template &lt;typename U = T, typename V= typename std::enable_if&lt; !std::is_same&lt; int, typename U::TRAIT&gt;::value, float &gt;::type&gt;
              Y( const V* =nullptr) { std::cout &lt;&lt; "Second" &lt;&lt; std::endl; }
  </code></pre>
  
  <p>};</p>
  
  <blockquote>
    <p>error: 'template template Y::Y(const V*)' cannot be overloaded</p>
  </blockquote>
  
  <p>But as already mentioned... I have no idea if that can be done.</p>
  
  <p>To show the underlying problem, I would give the following example which shows the different use of base class constructors dependent on a trait which is defined in the base class.</p>
  
  <pre><code>template &lt;typename T, typename ... S&gt;: public T
  class Z
  {
      public:
          // should work if T defines a trait
          Z( typename T::SomeType t): T( t ) {}
          // should be used if T defines another trait
          Z( typename T::SomeType t): T( )   {}
  };
  </code></pre>