title: Can I make use on templates when implementing different interfaces in the same way?
body: <p>I have many interfaces for different listeners, the all look like this:</p>
  <pre><code>class ListenerA
  {
  public:
      virtual void
      onEventA(const EventA&amp;) = 0;
  };
  
  class ListenerB
  {
  public:
      virtual void 
      onEventB(const EventB&amp;) = 0;
  };
  </code></pre>
  <p>When testing, I always end up just collecting those events in a <code>std::vector</code> for analyzing them afterwards in a specific test suite. Those event collectors all look the same like this one for example:</p>
  <pre><code>class EventACollector : public ListenerA
  {
  public:
  
      const auto&amp;
      events() const
      {
          return m_events;
      }
  
  private:
  
      void
      onEventA(const EventA&amp; event) override
      {
          m_events.emplace_back(event);
      }
  
      std::vector&lt;EventA&gt; m_events;
  };
  </code></pre>
  <p>Is there a way to template an EventTCollector, so that I do not have to write it every time? Given that the virtual function name does change for every listeners?</p>