mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-05-11 03:34:07 +00:00
added function autoclear_hook
This commit is contained in:
parent
11563f2b47
commit
e19ccbf5e5
11
tour.cpp
11
tour.cpp
@ -1100,12 +1100,13 @@ template<class T> void rv_keep(T& variable) {
|
|||||||
on_cleanup_or_next([backup, &variable] { variable = backup; });
|
on_cleanup_or_next([backup, &variable] { variable = backup; });
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class U> void rv_hook(hookset<T>& m, int prio, U&& hook) {
|
template<class T, class U> auto autoclear_hook(hookset<T>& m, int prio, U&& hook) {
|
||||||
int p = addHook(m, prio, hook);
|
int p = addHook(m, prio, hook);
|
||||||
auto del = [&m, p] {
|
return [&m, p] { delHook(m, p); };
|
||||||
delHook(m, p);
|
}
|
||||||
};
|
|
||||||
on_cleanup_or_next(del);
|
template<class T, class U> void rv_hook(hookset<T>& m, int prio, U&& hook) {
|
||||||
|
on_cleanup_or_next(autoclear_hook(m, prio, hook));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user