bind()ing a member boost::signal fails

I'm trying to use bind() on a class member variable of type boost::signal but it fails with the message (GCC 4.0.2): /usr/include/boost/noncopyable.hpp:27: error: ‘boost::noncopyable_::noncopyable::noncopyable(const boost::noncopyable_::noncopyable&)’ is private /usr/include/boost/signals/detail/signal_base.hpp:120: error: within this context I understand that signals are non-copyable per design, yet I'd like to be able to bind them somehow ;-) Is there a better way of doing that other than through a member function acting as a forwarding agent? For example: #include <boost/signal.hpp> #include <boost/bind.hpp> #include <boost/function.hpp> using namespace boost; struct foo { signal0<void> on_event; void on_event_fwd() { on_event(); } }; int main(int, char**) { foo fo; function0<void> f = bind(&foo::on_event, &fo); <-- doesn't compile // forward to signal, oh well // function0<void> f = bind(&foo::on_event_fwd, &fo); return 0; } Cheers, Slawomir Lisznianski

On 6/24/07, Slawomir Lisznianski <sl@paramay.com> wrote:
function0<void> f = bind(&foo::on_event, &fo); <-- doesn't compile
This does compile for me with Boost 1.34.0. But using Boost 1.33.1, I saw the same compile error. Since on_event is a function object you could bind it directly. You can then avoid making a copy by using Boost.Ref. function0<void> f = bind(ref(fo.on_event)); Daniel
participants (2)
-
Daniel Walker
-
Slawomir Lisznianski