Boost logo

Boost Users :

Subject: Re: [Boost-users] Beginner question: Why boost::signal creates another instance of the slot object ?
From: Mauricio Gomes (mgpensar_at_[hidden])
Date: 2010-08-19 18:32:48


Thank you very much Steven, boost::ref worked fine.

Just for my education, what is the rationale behind making a copy of
the signaled object ?
It seems odd to me since the object interested in receiving the event
ends up not receiving it (unless we use boost::ref).

I am obviously missing something conceptually here. If you or anyone
could explain it to me I'd really appreciate.

Thanks again.
Mau.

2010/8/19 Steven Watanabe <watanabesj_at_[hidden]>:
> AMDG
>
> Mauricio Gomes wrote:
>>
>> I am running the program below (Vista with boost 1.43, mingw/gcc 4.5.1).
>>
>> I would expect slot.x to be 5 but it is zero.
>>
>> Why boost::signal creates another instance of the slot object ?
>> What am I missing here ?
>
> boost::signal stores a copy of the function object.  If you
> don't want to make a copy use boost::ref.
>
> sig.connect(boost::ref(f));
>
> If you do this, you need to be careful that the
> function object doesn't go out of scope too soon.
>
> In Christ,
> Steven Watanabe
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>

-- 
Mau

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