title: c++ functor and function templates
body: <p>consider this simple and pointless code.</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  struct A {
      template&lt;int N&gt;
      void test() {
          std::cout &lt;&lt; N &lt;&lt; std::endl;
      }
  };
  
  int main() {
      A a;
      a.test&lt;1&gt;();
  }
  </code></pre>
  
  <p>It is a very simple example of a function template. What if however, I wanted to replace <code>A::test</code> with an overloaded <code>operator()</code> to make it a functor?</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  struct A {
      template&lt;int N&gt;
      void operator()() {
          std::cout &lt;&lt; N &lt;&lt; std::endl;
      }
  };
  
  int main() {
      A a;
      a&lt;1&gt;(); // &lt;-- error, how do I do this?
  }
  </code></pre>
  
  <p>Certainly if the <code>operator()</code> took parameters which were dependent on the template, the compiler could possibly deduce the template. But I just can't figure out the proper syntax to specify template parameters with a parameterless functor.</p>
  
  <p><strong>Is there a proper way to do this?</strong></p>
  
  <p>Obviously, this code would work since it bypasses the functor syntax:</p>
  
  <pre><code>a.operator()&lt;1&gt;();
  </code></pre>
  
  <p>but that kinda defeats the purpose of it being a functor :-P.</p>