diff --git a/thread/SignalSlot.h b/thread/SignalSlot.h index eb98dfe..11dad5a 100644 --- a/thread/SignalSlot.h +++ b/thread/SignalSlot.h @@ -120,22 +120,25 @@ class Signal : boost::noncopyable { } - Slot connect(Callback&& func) + template + Slot connect(Func&& func) { boost::shared_ptr slotImpl( - new SlotImpl(impl_, std::forward(func))); + new SlotImpl(impl_, std::forward(func))); add(slotImpl); return slotImpl; } - Slot connect(Callback&& func, const boost::shared_ptr& tie) + template + Slot connect(Func&& func, const boost::shared_ptr& tie) { - boost::shared_ptr slotImpl(new SlotImpl(impl_, func, tie)); + boost::shared_ptr slotImpl(new SlotImpl(impl_, std::forward(func), tie)); add(slotImpl); return slotImpl; } - void call(ARGS&&... args) + template + void call(Args&&... args) { SignalImpl& impl(*impl_); boost::shared_ptr slots; @@ -155,12 +158,12 @@ class Signal : boost::noncopyable guard = slotImpl->tie_.lock(); if (guard) { - slotImpl->cb_(args...); + slotImpl->cb_(std::forward(args)...); } } else { - slotImpl->cb_(args...); + slotImpl->cb_(std::forward(args)...); } } } diff --git a/thread/SignalSlotTrivial.h b/thread/SignalSlotTrivial.h index 0782b3a..cd8c6df 100644 --- a/thread/SignalSlotTrivial.h +++ b/thread/SignalSlotTrivial.h @@ -3,6 +3,7 @@ #include #include +#include template class SignalTrivial; @@ -13,19 +14,21 @@ class SignalTrivial public: typedef std::function Functor; - void connect(Functor&& func) + template + void connect(Func&& func) { - functors_.push_back(std::forward(func)); + functors_.push_back(std::forward(func)); } - void call(ARGS&&... args) + template + void call(Args&&... args) { // gcc 4.6 supports //for (const Functor& f: functors_) typename std::vector::iterator it = functors_.begin(); for (; it != functors_.end(); ++it) { - (*it)(args...); + (*it)(std::forward(args)...); } }