template <typename T> class TEvent: public Event { public: TEvent(const T& t): t_(t){} const T& t() const {return t_ ;} private: T t_ ; } ; class S: public Subscriber { public: template <typename T> void receives_event(TEvent<T>* e) { std::cerr << "receives " << typeid(T).name() << ": " << e->t() << std::endl ; } } ; int main() { Publisher p ; S s ; igs_connect(&p, &s, igs_functor(&s, S::receives_event<double>)) ; igs_connect(&p, &s, igs_functor(&s, S::receives_event<std::string>)) ; p.igs_emit(TEvent<double>(1.23)) ; p.igs_emit(TEvent<int>(123)) ; p.igs_emit(TEvent<std::string>("Hello World")) ; std::cerr << std::endl ; igs_disconnect(&p, &s, igs_functor(&s, S::receives_event<double>)) ; igs_disconnect(&p, &s, igs_functor(&s, S::receives_event<std::string>)) ; igs_connect(&p, &s, igs_functor(&s, S::receives_event<int>)) ; p.igs_emit(TEvent<double>(1.23)) ; p.igs_emit(TEvent<int>(123)) ; p.igs_emit(TEvent<std::string>("Hello World")) ; }Will print:
S receives d: 1.23 S receives Ss: Hello World S receives i: 123