title: Variadic template function: specialize head/tail and empty base case
body: <p>I'd like to have a variadic template function inside a class. The variadic template arguments are chars which should be processed in a loop-like manner. So I thought of writing it like in haskell with head/tail splitting the list until a base case (empty list) is reached.</p>
  
  <p>As an example, let's just count the number of arguments given (only a minimal example).</p>
  
  <p>I came up with the following code:</p>
  
  <pre><code>struct MyClass {
      template&lt;char ...X&gt;
      static int count();
  };
  
  
  template&lt;&gt;
  int MyClass::count&lt;&gt;() {
      return 0;
  }
  template&lt;char Head, char ...Tail&gt;
  int MyClass::count&lt;Head, Tail...&gt;() {
      return 1 + count&lt;Tail...&gt;();
  }
  </code></pre>
  
  <p>However, this <a href="http://ideone.com/ybuhxZ" rel="noreferrer">doesn't seem to work</a>:</p>
  
  <pre><code>prog.cpp:12:35: error: function template partial specialization ‘count&lt;Head, Tail ...&gt;’ is not allowed
  prog.cpp:12:5: error: prototype for ‘int MyClass::count()’ does not match any in class ‘MyClass’
  prog.cpp:3:16: error: candidate is: template&lt;char ...X&gt; static int MyClass::count()
  </code></pre>
  
  <p>How can I achieve this? I know that partial specialization isn't supported for functions. But I thought that specializing a variadic template into head/tail and empty base case version isn't a <em>partial</em> specialization but a <em>full</em> specialization, but maybe I'm wrong? Do I need to write this as a class instead of a function?</p>
  
  <p>I found examples (printf) which implement a base case without using the template syntax at all. But I guess that my case is different, since the call for printf doesn't use template syntax but <em>type deduction</em>, so <code>printf(tail...)</code> calls <code>printf()</code> if <code>tail</code> is empty. On the other side, in my case, when calling the base case, <code>count&lt;&gt;()</code> isn't the same as <code>count()</code>.</p>