Loading...
Searching...
No Matches
TfScopedVar< T > Class Template Reference

Reset variable on exiting scope. More...

#include <scoped.h>

Public Member Functions

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

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
}
Reset variable on exiting scope.
Definition: scoped.h:133

Definition at line 133 of file scoped.h.

Constructor & Destructor Documentation

◆ TfScopedVar()

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.

◆ ~TfScopedVar()

~TfScopedVar ( )
inline

Definition at line 148 of file scoped.h.


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