title: Pass pointer-to-template-function as function argument?
body: <p>Say I want a C++ function to perform arithmetic on two inputs, treating them as a given type:</p>
  
  <p>pseudo:</p>
  
  <pre><code>function(var X,var Y,function OP)
  {
   if(something)
    return OP&lt;int&gt;(X,Y);
   else if(something else)
    return OP&lt;double&gt;(X,Y);
   else
    return OP&lt;string&gt;(X,Y);
  }
  </code></pre>
  
  <p>functions that fit OP might be like:</p>
  
  <pre><code>template &lt;class T&gt; add(var X,var Y)
  {
   return (T)X + (T)Y; //X, Y are of a type with overloaded operators
  }
  </code></pre>
  
  <p>So, the question is what would the signature for function look like? If the operator functions are non-templated I can do it, but I get confused with this extra complexity.</p>