« Return to Thread: [Signals2] Signal disconnect wrapper won't work

Re: [Signals2] Signal disconnect wrapper won't work

by Marc DelaCruz :: Rate this Message:

Reply to Author | View in Thread

So I guess the 'best' workaround would be to do something like below?

template<typename T>
void disconnect (void (T::*pMemFunc)(void), T& rObj, VoidSignal& rSig)
{
    rSig.disconnect(VoidSlot(pMemFunc, rObj));
}

Thanks for the help.

-----Original Message-----
From: boost-users-bounces@...
[mailto:boost-users-bounces@...]On Behalf Of Steven Watanabe
Sent: Tuesday, July 07, 2009 9:42 AM
To: boost-users@...
Subject: Re: [Boost-users] [Signals2] Signal disconnect wrapper won't
work


AMDG

Marc dela Cruz wrote:
> Hopefully this is not another simple oversight on my part but I have code
like below and the disconnect wrapper does not work.

>
> Thanks.
>
> typedef boost::signals2::signal<void ()> VoidSignal;
> typedef VoidSignal::slot_type VoidSlot;
> class x{
> public:
> void somefuncA()
> {
>     cerr << "Bada bing" << endl;
> }
> void somefuncB()
> {
>     cerr << "Bada boom " << endl;
> }
> };
>
>
> void disconnect(VoidSlot const& rF, VoidSignal& rSig)
> {
>     rSig.disconnect(rF); //won't compile
>     //rSig.disconnect(&rF); //compiles but doesn't disconnect
> }
>
>
> int main()
> {
>     x myX;
>     VoidSignal sig;
>     sig.connect(VoidSlot(&x::somefuncB, &myX));
>     disconnect(VoidSlot(&x::somefuncB, &myX, sig); //doesn't work/compile
as expected
>     disconnect(boost::bind(&x::somefuncB, &myX, sig); //doesn't
work/compile either
>     sig(); // will still invoke somefuncB
>     return 0;
> }
>

Ignoring all the minor syntax errors, my guess is that
the basic problem is
http://www.boost.org/doc/html/function/faq.html#id1877737

In Christ,
Steven Watanabe

_______________________________________________
Boost-users mailing list
Boost-users@...
http://lists.boost.org/mailman/listinfo.cgi/boost-users


_______________________________________________
Boost-users mailing list
Boost-users@...
http://lists.boost.org/mailman/listinfo.cgi/boost-users

 « Return to Thread: [Signals2] Signal disconnect wrapper won't work