title: std::bind and std::function overlap or complementary?
body: <p>I was looking at <a href="http://thisthread.blogspot.be/2010/05/boostfunction-and-command-pattern.html" rel="nofollow">this exemple here</a>, combining std::bind and std::function so as to create a command: really neat! The code for the command class goes like this:</p>
  
  <pre><code>class Command
  {
   private:
     std::function&lt;void ()&gt; _f;
  
   public:
     command() {}
     command(std::function&lt;void ()&gt; f) : _f(f) {}
  
     template &lt;typename T&gt; void setFunction (T t) {_f = t ;}
     void execute()
      {
          if(!_f.empty())
              _f();
      }
  };
  </code></pre>
  
  <p>Assuming I have a class <code>MyClass</code> containing a member function:</p>
  
  <pre><code>class MyClass
  {
  public:
      void myMemberFn() {}
  }
  </code></pre>
  
  <p>Then the calling code looks like:</p>
  
  <pre><code>MyClass myClass;
  
  command(std::bind(&amp;MyClass::myMemberFn, myClass));
  </code></pre>
  
  <p>Though I must admit I do not really understand why <code>std::function</code> is needed in addition to <code>std::bind</code>. It seems to me that bind already encapsulates the function call, so why is function needed in <code>Command</code>? Couldn't <code>Command</code>store a <code>std::bind</code> rather than a <code>std::function</code>?</p>
  
  <p>I have been looking at documentation for both <a href="http://en.cppreference.com/w/cpp/utility/functional/bind" rel="nofollow">std::bind</a> and <a href="http://en.cppreference.com/w/cpp/utility/functional/function" rel="nofollow">std::function</a> and did not get it... </p>
  
  <p>Anyone has an idea of why <code>std::function</code>is needed?</p>
  
  <p><strong>PS:</strong> I am assuming std::bind ~= boost::bind and std::function ~= boost::function</p>