Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: base/memory/scoped_vector.h

Issue 18131002: ScopedVector - fix const semantics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_MEMORY_SCOPED_VECTOR_H_ 5 #ifndef BASE_MEMORY_SCOPED_VECTOR_H_
6 #define BASE_MEMORY_SCOPED_VECTOR_H_ 6 #define BASE_MEMORY_SCOPED_VECTOR_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 23 matching lines...) Expand all
34 34
35 ScopedVector() {} 35 ScopedVector() {}
36 ~ScopedVector() { clear(); } 36 ~ScopedVector() { clear(); }
37 ScopedVector(RValue other) { swap(*other.object); } 37 ScopedVector(RValue other) { swap(*other.object); }
38 38
39 ScopedVector& operator=(RValue rhs) { 39 ScopedVector& operator=(RValue rhs) {
40 swap(*rhs.object); 40 swap(*rhs.object);
41 return *this; 41 return *this;
42 } 42 }
43 43
44 T*& operator[](size_t index) { return v_[index]; } 44 reference operator[](size_t index) { return v_[index]; }
45 const T* operator[](size_t index) const { return v_[index]; } 45 const_reference operator[](size_t index) const { return v_[index]; }
46 46
47 bool empty() const { return v_.empty(); } 47 bool empty() const { return v_.empty(); }
48 size_t size() const { return v_.size(); } 48 size_t size() const { return v_.size(); }
49 49
50 reverse_iterator rbegin() { return v_.rbegin(); } 50 reverse_iterator rbegin() { return v_.rbegin(); }
51 const_reverse_iterator rbegin() const { return v_.rbegin(); } 51 const_reverse_iterator rbegin() const { return v_.rbegin(); }
52 reverse_iterator rend() { return v_.rend(); } 52 reverse_iterator rend() { return v_.rend(); }
53 const_reverse_iterator rend() const { return v_.rend(); } 53 const_reverse_iterator rend() const { return v_.rend(); }
54 54
55 iterator begin() { return v_.begin(); } 55 iterator begin() { return v_.begin(); }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 // Like |erase()|, but doesn't delete the elements in [first, last). 121 // Like |erase()|, but doesn't delete the elements in [first, last).
122 iterator weak_erase(iterator first, iterator last) { 122 iterator weak_erase(iterator first, iterator last) {
123 return v_.erase(first, last); 123 return v_.erase(first, last);
124 } 124 }
125 125
126 private: 126 private:
127 std::vector<T*> v_; 127 std::vector<T*> v_;
128 }; 128 };
129 129
130 #endif // BASE_MEMORY_SCOPED_VECTOR_H_ 130 #endif // BASE_MEMORY_SCOPED_VECTOR_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698