title: EventEmitter Class in C++ : Listener and Emitter
body: <p>I am trying to implement a class that would allow listening on some events and when these emits are emitted, they would get notifications.</p>
  
  <p>So i thought of using Functors,</p>
  
  <pre><code> class MyFunctor {
      public:     
          virtual void emit() {}
              vitual void compare() {} 
   };
  
   class MyFunctorSpecial : public MyFunctor {
      void (*)() ab;
      public:
      MyFunctorSpecial(void (*a)()) : ab(a) {}
      void emit() { ab(); }
   };
   class EventEmitter {
     std::map&lt;std::string, std::vector&lt;MyFunctor&gt; &gt; eventMap;
     public:
      void On(const std::string &amp;, const MyFunctor &amp;) {
          // add to the map
      }
  
      void Emit(const std::string &amp; eventName) {
          // emit the event
          // for all listeners in the vector for this event-name
           // call the emit of them. 
      }
   };
  
   EventEmitter emitter;
   // some function - abc()
   MyFunctorSpecial funct(abc);
   emitter.On("hello", funct);
   emitter.Emit("hello");
  </code></pre>
  
  <p>But now i want to pass arguments to the listeners. Like</p>
  
  <pre><code> emitter.Emit("hello", 45, false);
  </code></pre>
  
  <p>I think that this information would be available to <code>Emit()</code> at compile time, about the data-types of the various arguments. Can i use that information to make it happen , using templates or anything.</p>
  
  <p>If there is another kind of pattern for this problem? How can I do this?</p>