title: templated operator() overload C++
body: <p>someone already asked this question, but the thread ended up with the original question not getting answered.</p>
  
  <p>suppose you have this:</p>
  
  <pre><code>template&lt;size_t i, class f_type&gt;
  void call_with_i(f_type f);
  </code></pre>
  
  <p>functor_type is either:</p>
  
  <p>a) a struct with a method that has the following signature:</p>
  
  <pre><code>template&lt;size_t i&gt; operator()() const;
  </code></pre>
  
  <p><strike>
   or, b) a function that looks like this:</p>
  
  <pre><code>template&lt;size_t i&gt; foo();
  </code></pre>
  
  <p></strike></p>
  
  <p>I want "call_with_i&lt;42>(foo)" to be equivalent to "foo&lt;42>()", but I can't figure out the right syntax to make that happen. I'd be satified with a solution that does just (a) <strike>but (a)+(b) would be great</strike>. I've already tried these syntaxes:</p>
  
  <pre><code>f&lt; i &gt;(); // doesn't work
  f()&lt; i &gt;; // doesn't work
  f.operator&lt; i &gt;(); // doesn't work
  f.operator()&lt; i &gt;; // doesn't work
  f.operator()&lt; i &gt;(); // works on msvc, but doesn't work on gcc. 
  </code></pre>
  
  <p><strong>How do you invoke operator() with explicit template arguments? <strike>Is there a way to invoke it in a way that the same syntax would also call a templated free function?</strike></strong></p>
  
  <p>p.s. If you're wondering what i'm using this for, its because I'm writing a function repeat_to where repeat_to&lt;10>(f) invokes f(0) then f(1) ... f(10). I'm using this to iterate through multiple boost::fusion vectors in parallel by index. yeah, i could use iterators, or i could just use a named member function, but i still want to know the answer.</p>
  
  <p>edit note: i striked out stuff because passing a templated free function as an arg doesn't make any sense.</p>