diff options
author | Robert Vollmert <rvollmert@gmx.net> | 2010-01-20 16:43:21 +0100 |
---|---|---|
committer | Robert Vollmert <rvollmert@gmx.net> | 2010-01-20 17:08:02 +0100 |
commit | c7ee5f5347bbea6bfff96984065f90b51ea513ea (patch) | |
tree | 36771f4b087cd8e8792284da2e46e7f9643758cd /crawl-ref/source/unwind.h | |
parent | 623638dc03d8f233cd80eec9d6de30a504fe64ca (diff) | |
download | crawl-ref-c7ee5f5347bbea6bfff96984065f90b51ea513ea.tar.gz crawl-ref-c7ee5f5347bbea6bfff96984065f90b51ea513ea.zip |
Remove libutil.h from AppHdr.h and include explicitly.
Also extract unwind_var template to unwind.h. The latter is now
included from AppHdr.h, though it needn't really be.
This means it's now possible to use coord_def in libutil.h.
Diffstat (limited to 'crawl-ref/source/unwind.h')
-rw-r--r-- | crawl-ref/source/unwind.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/crawl-ref/source/unwind.h b/crawl-ref/source/unwind.h new file mode 100644 index 0000000000..1f1a85e807 --- /dev/null +++ b/crawl-ref/source/unwind.h @@ -0,0 +1,40 @@ +#ifndef UNWIND_H +#define UNWIND_H + +template <typename T> +class unwind_var +{ +public: + unwind_var(T &val_, T newval, T reset_to) : val(val_), oldval(reset_to) + { + val = newval; + } + unwind_var(T &val_, T newval) : val(val_), oldval(val_) + { + val = newval; + } + unwind_var(T &val_) : val(val_), oldval(val_) { } + ~unwind_var() + { + val = oldval; + } + + T value() const + { + return val; + } + + T original_value() const + { + return oldval; + } + +private: + T &val; + T oldval; +}; + +typedef unwind_var<bool> unwind_bool; + +#endif + |