Boost logo

Boost Users :

Subject: [Boost-users] [Signals2] Signal disconnect wrapper won't work
From: Marc dela Cruz (mdelacruz_at_[hidden])
Date: 2009-07-07 01:03:55


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;
}


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net