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

#include <scoped.h>

Public Member Functions

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

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

template<typename T>
TfScopedVar< T >::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.

template<typename T>
TfScopedVar< T >::~TfScopedVar ( )
inline

Definition at line 148 of file scoped.h.


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