I am writing a C++11 program that involves events and callbacks. I have a base class called Event, it's then derived by concrete event classes.
template <typename EventArgs>
class Event {
public:
using EventHandler = std::function<void(EventArgs)>;
void operator +=(EventHandler handlerDelegate);
void fire(EventArgs e);
private:
std::vector<EventHandler> subscribers;
};
std::vector<EventHandler> subscribers;
};
struct TouchEventArgs { int x, int y }
struct TouchEvent : public Event<TouchEventArgs> { }
...
I was wondering if something like this was possible:
template <typename EventArgs>
using event = struct : public Event<EventName> { };
So that i could declare events like
event<TouchEventArgs> TouchEvent;
Aucun commentaire:
Enregistrer un commentaire