title: C++ Template template for unit testing
body: <p>I'm experimenting with using C++'s template template features to reduce code duplication in a small unit test segment in my code, to no success. I've seen <a href="https://stackoverflow.com/questions/10871100/pass-a-function-as-an-explicit-template-parameter">these</a> <a href="https://stackoverflow.com/questions/1174169/function-passed-as-template-argument">answers</a> to similar questions, but still can't figure out what my compiler is telling me.</p>
  
  <p>I deal with some classes that do numerical processing at different precisions, and so I thought that I could generalize the duplicate code to a templated function, so it could be easily called by the class tests, as in:</p>
  
  <pre><code>template&lt;typename T, size_t S&gt;
  void CompareArrays(
      std::array&lt;T, S&gt; const &amp;input,
      std::array&lt;T, S&gt; const &amp;output) {...}
  
  template &lt;typename T&gt;
  void SomeClassTest::SomeClassIdentity() const {
      SomeClass&lt;T&gt; scZero;
      std::array&lt;T, 1&gt; const input = { 1 };
      auto output = scZero.Process(input);
      CompareArrays(input, output); // does the actual printing
  }
  </code></pre>
  
  <p>And then, test a lot of operations similar to <code>SomeClassTest::SomeClassIdentity</code> with a template template function:</p>
  
  <pre><code>template&lt;template &lt;typename&gt; typename F&gt;
  void CheckAgainstNumericTypes() {
      std::cerr &lt;&lt; "Testing with char...";
      F&lt;char&gt;();
      std::cerr &lt;&lt; "Testing with short...";
      F&lt;short&gt;();
      std::cerr &lt;&lt; "Testing with int...";
      F&lt;int&gt;();
      std::cerr &lt;&lt; "Testing with float...";
      F&lt;float&gt;();
      std::cerr &lt;&lt; "Testing with double...";
      F&lt;double&gt;();
  }
  </code></pre>
  
  <p>The problem is, every time I try to invoke <code>CheckAgainstNumericTypes</code>, the compiler will refuse with the error message "Invalid Template Argument for 'F', type expected", as in the example below:</p>
  
  <pre><code>void SomeClassTest::Test() const {
      std::cerr &lt;&lt; "Some Class Tests #1 - base/identity case" &lt;&lt; std::endl;
      CheckAgainstNumericTypes&lt;SomeClassIdentity&gt;();
      ...
  </code></pre>
  
  <p>I tried making <code>CheckAgainstNumericTypes</code> a member function of <code>SomeClass</code>, prepending the template argument with <code>SomeClass::</code>, adding <code>()</code> to the end of it, and even replacing the inner <code>typedef</code> by <code>void(*F)(void)</code>; all to no avail.</p>
  
  <p>I have two questions, then:</p>
  
  <ul>
  <li>How can I transform my member function into a type so it is accepted by the template?</li>
  <li>Is there any other way of accomplishing the same desired syntactic result in <code>SomeClassTest::Tests()</code> <em>without using</em> template templates?</li>
  </ul>