Skip to content

Commit

Permalink
ScopedVector - fix const semantics.
Browse files Browse the repository at this point in the history
const std::vector<T*> returns a const reference to a T* for
operator[]. const ScopedVector<T> instead returns a const T*, which
means the two have slightly differing semantics.

Fix ScopedVector to behave like std::vector instead - the reference
to the pointer is const, but the pointer is not const.

TBR=willchan@chromium.org
R=brettw@chromium.org

Review URL: https://chromiumcodereview.appspot.com/18131002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209537 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
groby@chromium.org committed Jul 1, 2013
1 parent af3e1ea commit f3a8f42
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions base/memory/scoped_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class ScopedVector {
return *this;
}

T*& operator[](size_t index) { return v_[index]; }
const T* operator[](size_t index) const { return v_[index]; }
reference operator[](size_t index) { return v_[index]; }
const_reference operator[](size_t index) const { return v_[index]; }

bool empty() const { return v_.empty(); }
size_t size() const { return v_.size(); }
Expand Down

0 comments on commit f3a8f42

Please sign in to comment.