Skip to content

Commit

Permalink
rogueviz:: rv_keep
Browse files Browse the repository at this point in the history
  • Loading branch information
zenorogue committed Aug 22, 2023
1 parent b2668e4 commit 572866b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rogueviz/rogueviz.h
Original file line number Diff line number Diff line change
Expand Up @@ -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] {
Expand Down

0 comments on commit 572866b

Please sign in to comment.