You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am moving from Qt signals/slots and I use this pattern all over the place:
connect(src, &Source::method, [](...) {...});
The issue I have is that in these cases I do not wish to manage the lifetime of the callback. Of course, since nano-signal-slot doesn't manage the lifetime of a callback this fails to compile:
somesignal->connect([](...){...});
Do you have a suggestion that can tie callback to the lifetime of the somesignal object? For the life of me I cannot figure out a way to track the lifetime without the signal taking ownership.
The text was updated successfully, but these errors were encountered:
Hello, in order for nano-signal-slot to support arbitrary slot disconnect, the connect would either need to return a disconnect object or it would need to consume a disconnect object.
Returning disconnect objects "usually" results in a discard by most library clients in which case void is better than [[nodiscard]]. Consuming a disconnect object would require the connections to store additional data which may or may not be used by all clients. This violates the "don't pay for what you don't use" goal of nano-signal-slot.
The only alternative is to externalize this cost to the client and force them to maintain their own disconnect scheme for non-Observer derived slots.
I am moving from Qt signals/slots and I use this pattern all over the place:
The issue I have is that in these cases I do not wish to manage the lifetime of the callback. Of course, since nano-signal-slot doesn't manage the lifetime of a callback this fails to compile:
Do you have a suggestion that can tie callback to the lifetime of the
somesignal
object? For the life of me I cannot figure out a way to track the lifetime without the signal taking ownership.The text was updated successfully, but these errors were encountered: