Index: src/smart-pointers.h |
diff --git a/src/smart-pointers.h b/src/smart-pointers.h |
index 345c4d47fb73e8d3e0c10c7f80fc87530876dbb3..02025bb7960b436bd41c8e85622dfebd251e30ee 100644 |
--- a/src/smart-pointers.h |
+++ b/src/smart-pointers.h |
@@ -58,11 +58,16 @@ class SmartPointerBase { |
// You can get the underlying pointer out with the * operator. |
inline T* operator*() { return p_; } |
- // You can use [n] to index as if it was a plain pointer |
+ // You can use [n] to index as if it was a plain pointer. |
inline T& operator[](size_t i) { |
return p_[i]; |
} |
+ // You can use [n] to index as if it was a plain pointer. |
+ const inline T& operator[](size_t i) const { |
+ return p_[i]; |
+ } |
+ |
// We don't have implicit conversion to a T* since that hinders migration: |
// You would not be able to change a method from returning a T* to |
// returning an SmartArrayPointer<T> and then get errors wherever it is used. |
@@ -77,6 +82,11 @@ class SmartPointerBase { |
return temp; |
} |
+ inline void Reset(T* new_value) { |
+ if (p_) Deallocator::Delete(p_); |
+ p_ = new_value; |
+ } |
+ |
// Assignment requires an empty (NULL) SmartArrayPointer as the receiver. Like |
// the copy constructor it removes the pointer in the original to avoid |
// double freeing. |