1#ifndef MUDUO_BASE_SIGNALSLOTTRIVIAL_H 2#define MUDUO_BASE_SIGNALSLOTTRIVIAL_H 3 4#include <memory> 5#include <vector> 6 7template<typename Signature> 8class SignalTrivial; 9 10template <typename RET, typename... ARGS> 11class SignalTrivial<RET(ARGS...)> 12{ 13 public: 14 typedef std::function<void (ARGS...)> Functor; 15 16 void connect(Functor&& func) 17 { 18 functors_.push_back(std::forward<Functor>(func)); 19 } 20 21 void call(ARGS&&... args) 22 { 23 // gcc 4.6 supports 24 //for (const Functor& f: functors_) 25 typename std::vector<Functor>::iterator it = functors_.begin(); 26 for (; it != functors_.end(); ++it) 27 { 28 (*it)(args...); 29 } 30 } 31 32 private: 33 std::vector<Functor> functors_; 34}; 35 36#endif // MUDUO_BASE_SIGNALSLOTTRIVIAL_H 37