Changeset c8dfcd3 for src/Common
- Timestamp:
- Aug 30, 2016, 5:15:34 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- fba44f8
- Parents:
- fa463f1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Common/utility.h
rfa463f1 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.