hook deletion

This commit is contained in:
Zeno Rogue 2020-09-11 11:17:12 +02:00
parent acc9b40431
commit db646aba5d
1 changed files with 9 additions and 1 deletions

10
hyper.h
View File

@ -458,9 +458,13 @@ public:
prio++;
}
map_->emplace(prio, static_cast<U&&>(hook));
return 0;
return prio;
}
void del(int prio) {
map_->erase(prio);
}
template<class... U>
void callhooks(U&&... args) const {
if (map_ == nullptr) return;
@ -709,6 +713,10 @@ template<class T, class U> int addHook(hookset<T>& m, int prio, U&& hook) {
return m.add(prio, static_cast<U&&>(hook));
}
template<class T> void delHook(hookset<T>& m, int prio) {
m.del(prio);
}
template<class T, class... U> void callhooks(const hookset<T>& h, U&&... args) {
return h.callhooks(static_cast<U&&>(args)...);
}