|
Boost Users : |
Subject: Re: [Boost-users] Connecting signals where one is a member
From: Frank Mori Hess (fmh6jj_at_[hidden])
Date: 2013-11-01 14:26:37
On Fri, Nov 1, 2013 at 1:04 PM, Chris Stankevitz
<chrisstankevitz_at_[hidden]> wrote:
> 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 <boost/signals2/signal.hpp>
>
> typedef boost::signals2::signal<void( )> TDSignalA;
> typedef boost::signals2::signal<void(int)> 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_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Frank
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