Le 20/05/15 15:25, Sylvester-Bradley, Gareth a écrit :
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)
Wow, I missed this functionality. Thanks a lot for sharing, Vicente