0

I want to achive the following behavior. In a base class I wish to have a container to store pointers to methods of derived class. (I want to store there h1 and h2). Base class is also implementing methods allowing to store those pointers and the container itself

There is not any code ready yet, cause I wonder whether it's possible at all - eg:

template<typename E, typename S>
using Map = std::unordered_map<E, std::function<S* (S&, void)>>;

template<typename E, typename S>
class Base {
someFunctToPutPointersIntoMap() {}
Map<E, S> mEventMap;
}

template<typename E, typename S>
class Derived: public Base<E, S> {

  public:
    Derived* h1(void) {};
    Derived* h2(void) {};

};

However how then I can declare object of derived class? For me its parameters are recursive eg.

Derived<E, Derived<E, Derived<E, Derived<E, ...etc... > object;

So it will never compile. I am sure there is some way to handle it, however I have none idea.

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
stanleysts
  • 41
  • 3

0 Answers0