1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-26 01:50:36 +00:00

rogueviz:: rv_keep

This commit is contained in:
Zeno Rogue 2023-08-22 20:06:52 +02:00
parent b2668e4cf5
commit 572866b67a

View File

@ -133,6 +133,11 @@ namespace rogueviz {
on_cleanup_or_next([backup, &variable] { variable = backup; });
}
template<class T> void rv_keep(T& variable) {
T backup = variable;
on_cleanup_or_next([backup, &variable] { variable = backup; });
}
template<class T, class U> void rv_hook(hookset<T>& m, int prio, U&& hook) {
int p = addHook(m, prio, hook);
auto del = [&m, p] {