title: template argument deduction/substitution failed, when using std::function and std::bind
body: <p>I have a compile error when using std::function in a templated member function, the following code is a simple example:</p>
  
  <pre><code>#include &lt;functional&gt;
  #include &lt;memory&gt;
  using std::function;
  using std::bind;
  using std::shared_ptr;
  
  class Test {
  public:
       template &lt;typename T&gt;
       void setCallback(function&lt;void (T, int)&gt; cb); 
  };
  
  template &lt;typename T&gt;
  void Test::setCallback(function&lt;void (T, int)&gt; cb)
  {
      // do nothing
  }
  
  class TestA {
  public:
      void testa(int a, int b) {   }
  };
  
  
  int main()
  {
      TestA testA;
      Test test;
      test.setCallback(bind(&amp;TestA::testa, &amp;testA, std::placeholders::_1, std::placeholders::_2));
      return 0;
  }
  </code></pre>
  
  <p>And come with the following compile error:</p>
  
  <blockquote>
    <p>testtemplate.cpp: In function ‘int main()’:</p>
    
    <p>testtemplate.cpp:29:92: error: no matching function for call to
    ‘Test::setCallback(std::_Bind_helper)(int, int),
    TestA, const std::_Placeholder&lt;1>&amp;, const
    std::_Placeholder&lt;2>&amp;>::type)’</p>
    
    <p>testtemplate.cpp:29:92: note: candidate is: testtemplate.cpp:10:7:
    note: template void Test::setCallback(std::function)</p>
    
    <p>testtemplate.cpp:10:7: note:   template argument
    deduction/substitution failed:</p>
    
    <p>testtemplate.cpp:29:92: note:   ‘std::_Bind(TestA*, std::_Placeholder&lt;1>,
    std::_Placeholder&lt;2>)>’ is not derived from ‘std::function’</p>
  </blockquote>
  
  <p>I'm using C++11 and g++ 4.7</p>