Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

strmod::strmod::StackSwapper< T > Class Template Reference

A class to make a certain means of doing dynamic scoping in a lexically scoped language exception safe. More...

#include <StrMod/StackSwapper.h>

List of all members.

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.


Detailed Description

template<class T>
class strmod::strmod::StackSwapper< T >

A class to make a certain means of doing dynamic scoping in a lexically scoped language exception safe.

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.


Constructor & Destructor Documentation

template<class T>
strmod::strmod::StackSwapper< T >::StackSwapper T &    classvar,
const T &    newval
[inline]
 

Saves the value in classvar, then sets classvar to newval.

Parameters:
classvar A reference to the variable who's valued is to be saved, then restored on scope exit.
newval The new value to be stored in classvar.

Definition at line 74 of file StackSwapper.h.


The documentation for this class was generated from the following file:
Generated on Wed Jan 29 00:32:55 2003 for libNet by doxygen1.3-rc1