Created
November 4, 2015 00:04
-
-
Save mannewalis/ae423ad24d297d89749a to your computer and use it in GitHub Desktop.
possible solution to registering/deregistering function callbacks using this to disambiguate.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class dispatch | |
{ | |
public: | |
void register(void* instance, std::function& callback) | |
{ | |
auto id = hash(instance, callback.target()); | |
map[id] = callback; | |
} | |
void unregister(void* instance, std::function& callback) | |
{ | |
auto id = hash(instance, callback.target()); | |
auto it = map.find(id); | |
if (it != map.end()) | |
{ | |
map.erase(it); | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment