
AMDG david.weber@l-3com.com wrote:
Ah. If you can somehow know what type slot holds, then it would work. See http://www.boost.org/doc/html/function/faq.html#id2914032
Hrm. I read it, and understand the reasons why, but then I read this: "The Signals library has a way around this."
I was wondering if you had any insight, and could elaborate further, as this is functionality that would make our implementation significantly simpler. We do have a well-defined function prototype, and all the code is being written as we speak, so it's simple enough to enforce certain restrictions to gain the functionality (if possible)
You have to know what the real type of the slot is when you call disconnect. Unless you are passing a single type of function pointer, you can template the connect and disconnect functions. Here's an extremely simplified example. #include <boost/signal.hpp> #include <boost/bind.hpp> #include <iostream> boost::signal<void()> sig; template<class F> void connect(F f) { sig.connect(f); } template<class F> void disconnect(F f) { sig.disconnect(f); } struct printer { typedef void result_type; void operator()(int i) const { std::cout << i << std::endl; } }; bool operator==(const printer&, const printer&) { return(true); } int main() { connect(boost::bind(printer(), 1)); sig(); disconnect(boost::bind(printer(), 1)); sig(); } In Christ, Steven Watanabe