Index: src/utils.h |
=================================================================== |
--- src/utils.h (revision 958) |
+++ src/utils.h (working copy) |
@@ -372,6 +372,23 @@ |
}; |
+// A temporary assignment sets a (non-local) variable to a value on |
+// construction and resets it the value on destruction. |
Mads Ager (chromium)
2008/12/15 08:36:30
it the -> the
|
+template <typename T> |
+class TempAssign { |
+ public: |
+ TempAssign(T* var, T value): var_(var), old_value_(*var) { |
+ *var = value; |
+ } |
+ |
+ ~TempAssign() { *var_ = old_value_; } |
+ |
+ private: |
+ T* var_; |
+ T old_value_; |
+}; |
+ |
+ |
template <typename T, int kSize> |
class EmbeddedVector : public Vector<T> { |
public: |