title: Using a template callback function in C++
body: <p>I want to have a function that checks certain conditions based on a given callback function.</p>
  
  <p>Considers this code:</p>
  
  <pre><code>class Foo{
  template &lt;class ParamType&gt;
  struct IsGood
  {
      typedef bool (*Check)(typename const ParamType*, int other);
  };
  template&lt; typename ParamType &gt;
  void DoSmth(IsGood&lt;ParamType&gt;::Check isGood, const ParamType* param){
     //...
     if(isGood(param, some_int_calculated_here)) doSmthElse();
  }
  </code></pre>
  
  <p>What I want is to call it with:</p>
  
  <pre><code>bool checkEqualInt(int* i, int j){return *i==j;}
  bool checkEqualFloat(float* i, float j){return *i==j;}
  
  DoSmth(checkEqualInt, &amp;i);
  DoSmth(checkEqualFloat, &amp;i_float);
  </code></pre>
  
  <p>(All constructed examples to show the problem)</p>
  
  <p>The compiler won't get that and throws me error C2664 "converting param 1 from bool(int*,int) in bool(ParamType,int) not possible"</p>
  
  <p>I there a solution without using </p>
  
  <pre><code>template&lt; typename ParamType, Check &gt;
  void DoSmth(Check isGood, const ParamType param)
  </code></pre>
  
  <p>Which ommits the necessary declaration of the check function?</p>
  
  <p>Best solution would be to get the IsGood() header in the function itself.</p>