Changes in src/Common/utility.h [79970ed:c8dfcd3]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Common/utility.h
r79970ed rc8dfcd3 246 246 } 247 247 248 // RAII object to regulate "save and restore" behaviour, e.g. 249 // void Foo::bar() { 250 // ValueGuard<int> guard(var); // var is a member of type Foo 251 // var = ...; 252 // } // var's original value is restored 253 template< typename T > 254 struct ValueGuard { 255 T old; 256 T& ref; 257 258 ValueGuard(T& inRef) : old(inRef), ref(inRef) {} 259 ~ValueGuard() { ref = old; } 260 }; 261 248 262 #endif // _UTILITY_H 249 263
Note: See TracChangeset
for help on using the changeset viewer.