title: Could not deduce template argument & pointer to member
body: <p>I am encountering the C2783 error with Visual C++ (could not deduce template argument), I have the following test case:</p>
  
  <pre class="lang-c prettyprint-override"><code>enum SPKType { A, B, C, D };
  
  template&lt;SPKType TypeCode, class ObjectType, typename U&gt;
  struct SPKSetterPattern
  {
      typedef void (ObjectType::* func)(U);
  };
  template&lt;class ObjectType, typename U&gt;
  struct SPKSetterPattern&lt;B,ObjectType,U&gt; { typedef void (ObjectType::* func)(U,U); };
  template&lt;class ObjectType, typename U&gt;
  struct SPKSetterPattern&lt;C,ObjectType,U&gt; { typedef void (ObjectType::* func)(U,U,U); };
  template&lt;class ObjectType, typename U&gt;
  struct SPKSetterPattern&lt;D,ObjectType,U&gt; { typedef void (ObjectType::* func)(U,U,U,U); };
  
  
  template&lt;typename ObjectType, SPKType TypeCode&gt;
  struct helper
  {
      template&lt;typename U&gt;
      static inline void add(ObjectType* obj, typename SPKSetterPattern&lt;TypeCode,ObjectType,U&gt;::func attrSetter) {}
      //static inline void add(ObjectType* obj, void (ObjectType::*attrSetter)(U)) {}
  };
  
  class test
  {
  public:
  template&lt;typename ObjType&gt;
  void init()
  {
      // Supposed to work
      helper&lt;ObjType,A&gt;::add(this, &amp;test::setA);
      //helper&lt;ObjType,B&gt;::add(this, &amp;test::setB);
      //helper&lt;ObjType,C&gt;::add(this, &amp;test::setC);
      //helper&lt;ObjType,D&gt;::add(this, &amp;test::setD);
      helper&lt;ObjType,A&gt;::add(this, &amp;test::setAf);
  
      // Supposed to fail
      //helper&lt;ObjType,B&gt;::add(this, &amp;test::setBf);
  }
  
  test() { init&lt;test&gt;(); }
  
  void setA(int a) {}
  void setB(float,float) {}
  void setC(int,int,int) {}
  void setD(int,int,int,int) {}
  
  void setAf(double a) {}
  void setBf(int,double) {}
  };
  
  int main()
  {
  test t;
  return 0;
  }
  </code></pre>
  
  <p>When commenting the line</p>
  
  <pre><code>static inline void add(ObjectType* obj, typename SPKSetterPattern&lt;TypeCode,ObjectType,U&gt;::func attrSetter) {}
  </code></pre>
  
  <p>and uncommenting the line following, the code compiles.</p>
  
  <p>I don't understand why, because for me the second argument of 'helper::add' is still the same...</p>
  
  <p>Thanks for help.</p>