[font="arial, verdana, tahoma, sans-serif"] [/font]
[font="arial, verdana, tahoma, sans-serif"]You could always create a wrapper object that allows you do uniquely identify the callbacks:[/font]
[font=arial, verdana, tahoma, sans-serif][/font]
[font=arial, verdana, tahoma, sans-serif]struct EventCallback[/font]
[font=arial, verdana, tahoma, sans-serif]
{[/font]
int id;
std::function callback;
};
However then you'd probably use a handle pattern, where the dispatcher allocates a unique ID that gets returned on registration, and the user holds on to that ID and uses it later for unregistration.Not necessarily ideal, but it does work without adding too much complexity to the implementation.
Yeah, I thought of something similar and it is definitely not ideal. I think this is where the observer pattern using interfaces has the upper hand; It's nice to be able to just pass the object in to unregister.
http://www.codeproje...stDelegate.aspx
Those are comparable if that's of any help... I've always had great success with them.
I've seen this, but only because I saw
this first and it is a response to that. I would probably use the "Impossibly Fast Delegates" if I were going to forgo std::function.