#include <StrMod/StackSwapper.h>
Public Methods | |
| StackSwapper (T &classvar, const T &newval) | |
| Saves the value in classvar, then sets classvar to newval. | |
| ~StackSwapper () | |
| Restores the value of the variable referenced by classvar in the constructor. | |
This could be thought of as maintaining a particular global or member variable (classvar) as the top stack value in a recursive function that maintained a stack of values on the execution stack.
This establishes something akin to dynamic scope.
Using the constructor and destructor to maintain these values causes this manipulation to be exception safe. It eliminates the need for a lot of try { } catch (...) { } blocks to clean stuff up and make things exception safe.
Definition at line 48 of file StackSwapper.h.
|
||||||||||||||||
|
Saves the value in classvar, then sets classvar to newval.
Definition at line 74 of file StackSwapper.h. |
1.3-rc1