Le 12/05/15 04:25, Emil Dotchevski a écrit :
Hello,
I realize that Boost has Signals library already, but I've implemented a non-intrusive one which approaches the problem differently, and I'm pretty sure that there is no overlap between the two. It turned out more generic than I originally anticipated, so I thought I'd ask if others would find it useful as well.
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.
Maybe a connect_member
auto c1 = connect_member