title: Passing a complex function variants as arguments
body: <p>Say I have the following template function:</p>
  
  <pre><code>template &lt;class T&gt;
  void apply(const vector&lt;complex&lt;T&gt; &gt;&amp; in, vector&lt;T&gt;&amp; out, T (*f)(complex&lt;T&gt;))
  {
      out.resize(in.size());
      for(size_t i = 0; i &lt; in.size(); ++i) out[i] = f(in[i]);
  }
  </code></pre>
  
  <p>You can see, I just want to apply a function to a vector of complex data, and store the results into a vector of real data. I figure this should be good for a whole list of function: abs, norm, real, imag, etc.</p>
  
  <p>My problem is, how do I pass a function in?</p>
  
  <p>I have tried variants of <code>apply(in, out, abs)</code> supplying different templates to <code>abs</code> with no luck. I am pretty sure the problem stems from the functions for complex all being templates, but I am not sure how to pass it properly. Thanks for the help.</p>