title: Passing a Functor as a param to a method
body: <p>I have the following two classes that exhibit the Command pattern.  (Unfortunately, both have a unique method name.)</p>
  
  <pre><code>//pseudocode 
  class Subscriber {
      virtual void receive(const Event&amp;) = 0;
  }
  
  class Dispatcher {
      virtual void dispatch(const Event&amp;) = 0;
  }
  </code></pre>
  
  <p>I have a class template that has a list of some type with a method to iterate over this list.</p>
  
  <pre><code>//pseudocode
  template&lt;typename T&gt;
  class Registry {
      typedef list&lt;T&gt; ObjectList;
      ObjectList _objects;
      void iterate(const Event&amp; event) {
          for_each(_objects.begin(), _objects.end(), ...);  //not sure what to do here
      }
  }
  </code></pre>
  
  <p>I would like to use <code>mem_fun</code> to create a Functor that calls <code>receive</code> or <code>dispatch</code> as appropriate.  I'm able to create a simple use case where I simply invoke a method without any params.  I.e.</p>
  
  <pre><code>//pseudocode
  class Simple {
      void simple() {/*...*/}
  }
  </code></pre>
  
  <p>and then I iterate:</p>
  
  <pre><code>for_each(_objects.begin(), _objects.end(), mem_fun(&amp;Simple::simple);
  </code></pre>
  
  <p>Unfortunately, I have no idea how to get the <code>event</code> param passed to mem_fun.  Looking at the headers, it does appear that I can pass a single param, but I'm not well versed in C++ to understand what I need to do.</p>
  
  <p>Ultimately, I would like to make the <code>iterate</code> method accept a type of functor so it will fire that method on every method in the list.</p>
  
  <p>I would prefer to avoid Boost...I think this is entirely possible without dragging this framework into the mix.</p>
  
  <p>Thanks!</p>