title: template class constructor with pointer to member function as parameter
body: <p>I have following setup, which gives me headaches because I don't see the problem:</p>
  
  <pre><code>ValidationModule module = ValidationModule(std::vector&lt;FilterFlag&gt;(0));
  Settings validationSettings = Settings("Validation Settings");
  validationSettings.registerFloat("test", module, &amp;ValidationModule::setRatio, &amp;ValidationModule::getRatio, 0.0f, 1.0f);
  </code></pre>
  
  <p><code>registerFloat</code> takes two pointers to member functions of <code>ValidationModule</code></p>
  
  <p>ValidationModule.h</p>
  
  <pre><code>// constructor
  ValidationModule(const std::vector&lt;FilterFlag&gt;&amp; filterFlags, float ratio = 0.7f);
  
  // getter and setter, which are passed to Settings::registerFloat
  inline void setRatio(float value) { _ratio = value; }
  inline float getRatio() const { return _ratio; }
  </code></pre>
  
  <p>Settings.h</p>
  
  <pre><code>template&lt;class TClass&gt;
  inline void Settings::registerFloat(const std::string&amp; name, TClass owner, void (TClass::*setter)(float), float (TClass::*getter)() const, float minValue, float maxValue)
  {
      CallBackToMemberSingleArg&lt;float, TClass&gt;* setterCallback = new CallBackToMemberSingleArg&lt;float, TClass&gt;(owner, setter);
      CallBackToMemberReturn&lt;float, TClass&gt;* getterCallback = new CallBackToMemberReturn&lt;float, TClass&gt;(owner, getter);
      // some unrelated processing
      [...]
  }
  </code></pre>
  
  <p><strong>The compiler gives me following errors</strong> for the two constructors of <code>CallBackToMemberSingleArg</code> and <code>CallBackToMemberReturn</code>:</p>
  
  <pre><code>No matching constructor for initialization of 'CallBackToMemberSingleArg&lt;float, ValidationModule&gt;'
  No matching constructor for initialization of 'CallBackToMemberReturn&lt;float, ValidationModule&gt;'
  </code></pre>
  
  <p>Here are the constructor declarations</p>
  
  <p>Callback.h</p>
  
  <pre><code>template &lt;typename TParam&gt;
  class CallBackSingleArg
  {
  public:
      virtual ~CallBackSingleArg() { }
      virtual void call(const TParam&amp; p) = 0;
  };
  
  template &lt;typename TParam, typename TClass&gt;
  class CallBackToMemberSingleArg : public CallBackSingleArg&lt;TParam&gt;
  {
      void (TClass::*function)(const TParam&amp;);
      TClass* object;
  public:
      CallBackToMemberSingleArg(TClass* object, void(TClass::*function)(const TParam&amp;)) : object(object), function(function) { };
      void call(const TParam&amp; p) {
          (*object.*function)(p);
      }
  };
  
  template &lt;typename TParam&gt;
  class CallBackReturn
  {
  public:
      virtual ~CallBackReturn() { }
      virtual TParam call() = 0;
  };
  
  template &lt;typename TParam, typename TClass&gt;
  class CallBackToMemberReturn : public CallBackReturn&lt;TParam&gt;
  {
      TParam (TClass::*function)();
      TClass* object;
  public:
      CallBackToMemberReturn(TClass* object, TParam(TClass::*function)()) : object(object), function(function) { };
      TParam call() {
          return (*object.*function)();
      }
  };
  </code></pre>
  
  <p>I tried to change the actual setter to <code>void setRatio(const float&amp; value)</code>, because <code>CallBackToMemberSingleArg</code> takes a const reference parameter, but that didn't help and also the call to the constructor of <code>CallBackToMemberReturn</code> gives the above error, so there must be something else, which I am unable to see.</p>