title: std::function with non-static member functions
body: <p>i'm trying to understand a concept and an error. what's wrong with this?</p>
  
  <pre><code>class A
  {
  public:
      A()
      {
          std::function&lt;void(int)&gt; testFunc(&amp;A::func);
      }
  
  private:
      void func(int) {}
  }
  </code></pre>
  
  <p>my question, is it possible to create any sort of object that is able to call a member of a specific instance where std::function acts like a member function pointer, except without the wacky type definition that can't be used as function parameters in inheriting classes. for example:</p>
  
  <pre><code>class A
  {
  public:
      A()
      {
           index[WM_CREATE] = &amp;A::close;
           index[WM_DESTROY] = &amp;A::destroy;
      }
  
  protected:
      map&lt;UINT msg, void (A::*)(HWND, UINT , WPARAM, LPARAM)&gt; index;
      void close(HWND,UINT, WPARAM, LPARAM);
      void destroy(HWND, UINT, WPARAM, LPARAM);
  };
  
  class B : public A
  {
  public:
      B()
      {
          index[WM_CREATE] = &amp;B::create; // error because it's not a pointer of type A::*
      }
  private:
      void create(HWND, UINT, WPARAM, LPARAM);
  
  };
  </code></pre>
  
  <p>I'm thinking i'm on the right track of using std::functions like so:</p>
  
  <pre><code>class A
  {
  public:             //         Gigantic stl error with these two
      A()             //                         |
      {               //                         V
           index[WM_CREATE] = std::function&lt;void(HWND, UINT, WPARAM, LPARAM&gt;(&amp;A::close);
           index[WM_DESTROY] = std::function&lt;void(HWND, UINT, WPARAM, LPARAM&gt;(&amp;A::destroy);
      }
  
  protected:
      map&lt;UINT msg, std::function&lt;void(HWND, UINT, WPARAM, LPARAM)&gt; &gt; index;
      void close(HWND,UINT, WPARAM, LPARAM);
      void destroy(HWND, UINT, WPARAM, LPARAM);
  };
  
  class B : public A
  {
  public:                    //               and this one
      B()                    //                     |
      {                      //                     V
          index[WM_CREATE] = std::function&lt;void(HWND, UINT, WPARAM, LPARAM)&gt;(&amp;B::create);
      }
  private:
      void create(HWND, UINT, WPARAM, LPARAM);
  
  };
  </code></pre>
  
  <p>if someone could explain what these giant cryptic errors mean and how to fix them, i would greatly appreciate it.</p>