A container of std::function with polymorphic types as function arguments
问题 I would like to have "yet another" callback registration stuff. Different event types extending a common base event type will trigger associated callback functions. here is the initial draft or idea #include <functional> #include <iostream> #include <unordered_map> class BaseEvent { public: virtual ~BaseEvent() {} }; class DerivedEvent_1 : public BaseEvent {}; class DerivedEvent_2 : public BaseEvent {}; // a container holding callback functions std::unordered_map<size_t/*event*/, std: