title: Is it possible to access the arguments from an std::bind object?
body: <p>Please consider the following scenario.</p>
  <p>A hypothetical pop-up menu class that displays some actions, and when one of them is selected it will call the passed in action which is in form of an <code>std::function</code>:</p>
  <pre><code>PopupMenu::PopupMenu(std::function&lt;void(RowItem*)&gt; editRowFunction, RowItem *item)
      : _editRowFunction(editRowFunction)
      , _item(item) {
  }
  </code></pre>
  <p>Then at some point it might call execute:</p>
  <pre><code>PopupMenu::execute(} {
      _editRowFunction(_item);
  }
  </code></pre>
  <p>Then I have this other class that's a UI object:</p>
  <pre><code>class EditorWidget {
      void editRow(RowItem *row) {
          //edit the row
      }
  }
  </code></pre>
  <p>And here's how I am using all of them:</p>
  <pre><code>int main() {
      auto item = new RowItem();
      auto editorWidget = new EditorWidget();
      PopupMenu menu(std::bind(&amp;EditorWidget::editRow, editorWidget, item), item);
      menu.execute();
      return 0;
  }
  </code></pre>
  <p>Everything works. My question is the following:
  If I am already passing the argument <code>item</code> in <code>std::bind</code>, why do I have to pass it again as a second parameter in order to be able to call the bound function with that argument? If I don't, and try to call the function just by itself from <code>PopupMenu::execute()</code>, I get a compiler error.</p>
  <p>The other way around it is to make the constructor of <code>PopupMenu</code> like this:</p>
  <pre><code>PopupMenu::PopupMenu(std::function&lt;void()&gt; editRowFunction)
      : _editRowFunction(editRowFunction) {}
  </code></pre>
  <p>And if I do it that way then I call it this way:</p>
  <pre><code>PopupMenu::execute() {
  _editRowFunction();
  }
  </code></pre>
  <p>What I don't like about this method is that I can pretty much pass any bound function in the <code>PopupMenu</code> constructor and it will be called. But that's not what I want, I want to enforce only a function with a specific signature.</p>
  <p>I can also pass a lambda, yes. But let's try to solve it without lambdas.
  Thank you all in advance for your help.</p>