Boost logo

Boost :

Subject: Re: [boost] Interest in non-intrusive signal/slot lib?
From: Sylvester-Bradley, Gareth (Gareth.Sylvester-Bradley_at_[hidden])
Date: 2015-05-20 09:25:13


On 20 May 2015 14:13, Vicente J. Botet Escriba wrote:
> I have some concerns about the lifetime of the emitters.
>
> E.g. an application can have a class that contains a several possible emitters. The lifetime of all the
> emitters depends on the lifetime of the C instance.
>
> struct C {
> T1 e1;
> T2 e2;
> };
>
> int main() {
>
> shared_ptr<C> c = make_shared<C>();
> // ...
>
> The lifetime of emitters c->e1 and c->e2 is managed by c.
>
> Now I would like to connect to c->e1 and/or c->e2. But I would need to change the class C, as I don't > have a shared_ptr to &(c->e1) or &(c->e2).
>
> Do you have a solution without changing C? If not, could your library take care of this use case? IMO
> this will reduce the need for more shared_ptr than really needed.

Doesn't an aliasing shared_ptr work for this?

I.e. boost::shared_ptr<T>(c, &c->e1)

Best regards,
Gareth

************************************************************************ The information contained in this message or any of its attachments may be confidential and is intended for the exclusive use of the addressee(s). Any disclosure, reproduction, distribution or other dissemination or use of this communication is strictly prohibited without the express permission of the sender. The views expressed in this email are those of the individual and not necessarily those of Sony or Sony affiliated companies. Sony email is for business use only. This email and any response may be monitored by Sony to be in compliance with Sony's global policies and standards


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk