title: member function implementation depending on template parameter
body: <p>I have the following problem:</p>
  
  <pre><code>template&lt; typename T, size_t N, size_t... N_i &gt;
  class A
  {  
    public:
  
      // ...
  
      // first implementation
      template&lt; size_t M = sizeof...(N_i)+1, typename std::enable_if&lt; M!=1, size_t &gt;::type = 0 &gt;
      A&lt;T, N_i...&gt; operator[]( size_t i )
      {
        A&lt; T, N_i... &gt; res{ ... };
  
        return res;
      }
  
      // second implementation
      template&lt; size_t M = sizeof...(N_i)+1, typename std::enable_if&lt; M==1, size_t &gt;::type = 0 &gt;
      T operator[]( size_t i )
      {
        return ... ;
      }
  };
  </code></pre>
  
  <p>As you can see above, I try to implement a class <code>A</code> which expects as template arguments a type <code>T</code> (e.g. <code>int</code> or <code>float</code>) and <code>sizeof...(N_i)+1</code>-many <code>size_t</code>.</p>
  
  <p>Dependent on the number of passed <code>size_t</code> (i.e. <code>sizeof...(N_i)+1</code>), I will use a different implementation for the member function <code>operator[](size_t)</code> with a different result type:</p>
  
  <ul>
  <li>one implementation for the case <code>sizeof...(N_i)+1 &gt; 1</code> with return type <code>A &lt; T, N_i... &gt;</code>
  (referred to as "first implementation" in the code) </li>
  <li>and one for the case <code>sizeof...(N_i)+1 == 1</code> with return type <code>T</code> 
  (referred to as "second implementation" in the code). </li>
  </ul>
  
  <p>Unfortunately, I have no idea how this can be implemented -- the solution above does not work. Has anyone an idea?</p>
  
  <p>Many thanks in advance.</p>