Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template<class Evt>
- class Multicast{
- public:
- template<class Fn>
- void addObserver(Fn&& obs){
- observers.push_back(obs);
- }
- void broadcast(Evt event){
- for ( auto& obs : observers ){
- obs(event);
- }
- }
- private:
- std::vector< std::function<void(Evt)> > observers;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement