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-20 17:31:06


The problem was my interpretation of what you meant by "properly copyable".

Thanks Lars.

2010/8/20 Lars Viklund <zao_at_[hidden]>:
> On Fri, Aug 20, 2010 at 04:25:07PM -0300, Mauricio Gomes wrote:
>> > As for your initial problem of the receiver being dis-associated from
>> > the callable, it's probably because it's not properly copyable
>> I thought the compiler would generate a copy constructor and
>> assignment operator suitable for S. Is not the case ?
>> --
>> Mau
>
> The synthesised cctor and op= will do a member-wise copy and
> assignment, respectively.
>
> If you have value members, the copy or target will contain copies of
> them.
>
> If you want to share state between two instances, you need to have
> reference members, reference_wrapper members or pointer-type members.
>
> Like say:
>
> struct S1
> {
>        shared_ptr<int> x;
> };
>
> or
>
> struct S2
> {
>        boost::reference_wrapper<int> x;
> };
>
> --
> Lars Viklund | zao_at_[hidden]
> _______________________________________________
> 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