All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TfScopedVar< T > Class Template Reference

Reset variable on exiting scope. More...

Public Member Functions

 TfScopedVar (T &x, const T &val)
 Set/reset variable. More...
 

Detailed Description

template<typename T>
class TfScopedVar< T >

Reset variable on exiting scope.

A TfScopedVar sets a variable to a value when created then restores its original value when destroyed. For example:

* int func(bool x) {
* TfScopedVar<bool> scope(x, true); // set x to true
* return func2(x); // restore x after calling func2
* }
*

Definition at line 133 of file scoped.h.

Constructor & Destructor Documentation

TfScopedVar ( T &  x,
const T &  val 
)
inlineexplicit

Set/reset variable.

Sets x to val immediately and restores its old value when this goes out of scope.

Definition at line 141 of file scoped.h.


The documentation for this class was generated from the following file: