Reputation: 4710
I would like to encapsulate a signals2::signal object ans expose the connect and operator() functions, but how does their prototypes look like?
Example:
#include <boost/signals2/signal.hpp>
template<typename T> class A {
public:
typedef boost::signals2::signal<T> SIG_T;
void connect( TYPE1 arg ){
s.connect(arg);
}
void fire ( TYPE2 arg ){
s(arg);
}
private:
SIG_T s;
};
So how to express the correct type for TYPE1 and TYPE2, I assume it is something like SIG_T::???
Upvotes: 2
Views: 771
Reputation: 254531
connect
takes typename SIG_T::slot_type const &
.
operator()
takes typename SIG_T::argument_type
(also defined as typename SIG_T::arg<0>::type
).
Alternatively, you could use templates to avoid worrying about the exact definition and accept anything convertible to the correct types:
template <typename Slot> void connect(Slot const & slot) {s.connect(slot);}
template <typename Arg> void fire(Arg const & arg) {s(arg);}
Upvotes: 2