14670cafeSShuo Chen#ifndef MUDUO_BASE_SIGNALSLOTTRIVIAL_H 24670cafeSShuo Chen#define MUDUO_BASE_SIGNALSLOTTRIVIAL_H 34670cafeSShuo Chen 44670cafeSShuo Chen#include <memory> 54670cafeSShuo Chen#include <vector> 64670cafeSShuo Chen 74670cafeSShuo Chentemplate<typename Signature> 84670cafeSShuo Chenclass SignalTrivial; 94670cafeSShuo Chen 104670cafeSShuo Chentemplate <typename RET, typename... ARGS> 114670cafeSShuo Chenclass SignalTrivial<RET(ARGS...)> 124670cafeSShuo Chen{ 134670cafeSShuo Chen public: 144670cafeSShuo Chen typedef std::function<void (ARGS...)> Functor; 154670cafeSShuo Chen 164670cafeSShuo Chen void connect(Functor&& func) 174670cafeSShuo Chen { 184670cafeSShuo Chen functors_.push_back(std::forward<Functor>(func)); 194670cafeSShuo Chen } 204670cafeSShuo Chen 214670cafeSShuo Chen void call(ARGS&&... args) 224670cafeSShuo Chen { 234670cafeSShuo Chen // gcc 4.6 supports 244670cafeSShuo Chen //for (const Functor& f: functors_) 254670cafeSShuo Chen typename std::vector<Functor>::iterator it = functors_.begin(); 264670cafeSShuo Chen for (; it != functors_.end(); ++it) 274670cafeSShuo Chen { 284670cafeSShuo Chen (*it)(args...); 294670cafeSShuo Chen } 304670cafeSShuo Chen } 314670cafeSShuo Chen 324670cafeSShuo Chen private: 334670cafeSShuo Chen std::vector<Functor> functors_; 344670cafeSShuo Chen}; 354670cafeSShuo Chen 364670cafeSShuo Chen#endif // MUDUO_BASE_SIGNALSLOTTRIVIAL_H 37