title: Event System with Template class deriving from Non-Template base class in c++
body: <h2>What I'm doing</h2>
  
  <p>I'm working on an event system. Basically there are "slots" which any member can chime into. All they need is an event name which it will be listening to, and a function. Since all the slots are stored I had to store them as a variable in a class.</p>
  
  <h2>The Problem</h2>
  
  <p>The function becomes unavailable when it's placed into the SlotBase class. I am wondering if there is a way to retain the function in the Slot class while storing in in the SlotBase class.</p>
  
  <h2>The Code</h2>
  
  <pre><code>class SlotBase { };
  //              TC - Template Class
  //                              TA - Template Arguments (types)
  template &lt;class TC, typename ...TA&gt;
  class Slot : public SlotBase  {
  public:
      Slot(TC* funcClass, void(TC::*func)(TA...)) {
          SetSlot(funcClass, func);
      }
      template &lt;int ...Is&gt;
      void SetSlot(TC* funcClass, void(TC::*func)(TA...), int_sequence&lt;Is...&gt;) {
          function = std::bind(func, funcClass, placeholder_temp&lt;Is&gt;{}...);
      }
      void SetSlot(TC* funcClass, void(TC::*func)(TA...)) {
          SetSlot(funcClass, func, make_int_sequence&lt;sizeof...(TA)&gt;{});
      }
      std::function&lt;void(TA...)&gt; returnFunction(){
          return function;
      }
  private:
      std::function&lt;void(TA...)&gt; function;
  };
  
  
  //...
  
  
  class RandomClass {
  public:
      void randomFunction(int a, float b, int c){ //do stuff };
  }
  
  
  //...
  
  
  RandomClass randC;
  SlotBase baseS;
  
  Slot newSlot(&amp;randC, &amp;RandomClass::randomFunction);
  baseS = newSlot;
  
  
  //...
  //Later on down the line when an event was found matching slot call slot function
  
  
  baseS.returnFunction()(//Correct arguments go here - leaving this out (a lot more code));
  </code></pre>
  
  <p>I didn't include the code for the integer sequences in the 'std::bind' as it isn't related to the problem.</p>
  
  <h2>What I have tried</h2>
  
  <p>I know that if I use a Slot cast on the <code>baseS</code> variable that would give me the result but I am unable to do so because I don't know the templates that Slot will have.</p>
  
  <p>I have seen many similar posts stating to make <code>baseS</code> a pointer (such as <a href="https://stackoverflow.com/questions/569073/c-stdmap-of-template-class-values">here</a>) but I still don't understand how you would grab the function.</p>