title: How can I expand this C++11 event system to handle multiple arguments?
body: <p>I've written a simple subscriber event system taking advantage of <code>std::function</code>. It works great! (and I can do some big enhancements later with thread-pooling for expensive callbacks)</p>
  
  <p>The next step to improve this is to handle events/callbacks with more than one parameter. </p>
  
  <p>Other than forcing <code>struct</code>s/<code>class</code>es or using <code>std::tuple</code>s in the callback arguments (I want to keep the functions clean or use existing simple funcs).  Is there a good way to do this, and have multiple template parameters all with the same code? </p>
  
  <pre><code>#pragma once
  
  #include &lt;mutex&gt;
  #include &lt;vector&gt;
  
  
  template&lt;typename PARAM&gt;
  class SoyEvent
  {
  public:
      typedef std::function&lt;void(PARAM&amp;)&gt; FUNCTION;
  
  public:
      //  helper for member functions
      template&lt;class CLASS&gt;
      void            AddListener(CLASS&amp; This,void(CLASS::*Member)(PARAM&amp;))
      {
          //  http://stackoverflow.com/a/7582576
          auto bound = std::bind( Member, &amp;This, std::placeholders::_1  );
          AddListener( bound );
      }
      template&lt;class CLASS&gt;
      void            RemoveListener(CLASS&amp; This,FUNCTION Member)
      {
          RemoveListener( std::bind( &amp;Member, &amp;This ) );
      }
  
      //  add static or lambda
      void            AddListener(FUNCTION Function)
      {
          std::lock_guard&lt;std::mutex&gt; lock(mListenerLock);
          mListeners.push_back(Function);
      }
      void            RemoveListener(FUNCTION Function)
      {
          std::lock_guard&lt;std::mutex&gt; lock(mListenerLock);
          mListeners.erase(Function);
      }
  
      void            OnTriggered(PARAM&amp; Param)
      {
          std::lock_guard&lt;std::mutex&gt; lock(mListenerLock);
  
          //  todo: execute on seperate threads with a scheduler which can just execute std::functions
          for ( auto it=mListeners.begin();   it!=mListeners.end();   it++ )
          {
              auto&amp; Function = *it;
              Function( Param );
          }
      }
  
  private:
      std::mutex      mListenerLock;
      std::vector&lt;FUNCTION&gt;   mListeners;
  };
  </code></pre>