Connecting signals where one is a member
Hello,
"Connect 4" fails to compile in the code below on g++ 4.6.3.
Why does "Connect 4" not work while "Connect 2" does work? Connect 4
and 2 are the same thing as far as I can see.
Thank you,
Chris
#include
On Fri, Nov 1, 2013 at 1:04 PM, Chris Stankevitz
Hello,
"Connect 4" fails to compile in the code below on g++ 4.6.3.
Why does "Connect 4" not work while "Connect 2" does work? Connect 4 and 2 are the same thing as far as I can see.
bind behaves a little differently than you seem to be assuming when dealing with pointers to data members, as opposed to pointers to member functions. Even though connect 2 compiles, it isn't doing the same thing that connect 1 does. From the mem_fn docs (referred to by the bind docs): "mem_fn also supports pointers to data members by treating them as functions taking no arguments and returning a (const) reference to the member."
Thank you,
Chris
#include
typedef boost::signals2::signal
TDSignalA; typedef boost::signals2::signal TDSignalB; TDSignalA SignalA1; TDSignalB SignalB1;
struct TSItem { TDSignalA SignalA2; TDSignalB SignalB2; };
int main() { TSItem Item;
// Connect 1 SignalA1.connect(Item.SignalA2);
// Connect 2 SignalA1.connect(TDSignalA::slot_type(&TSItem::SignalA2, &Item));
// Connect 3 SignalB1.connect(Item.SignalB2);
// Connect 4 //SignalB1.connect(TDSignalB::slot_type(&TSItem::SignalB2, &Item, _1));
return 0; } _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Frank
participants (2)
-
Chris Stankevitz
-
Frank Mori Hess