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

Side by Side Diff: cc/base/scoped_ptr_vector.h

Issue 16355009: Rewrite scoped_ptr<T>(NULL) to use the default ctor in cc/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix most vexing parse Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « cc/base/scoped_ptr_hash_map.h ('k') | cc/layers/delegated_renderer_layer_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 CC_BASE_SCOPED_PTR_VECTOR_H_ 5 #ifndef CC_BASE_SCOPED_PTR_VECTOR_H_
6 #define CC_BASE_SCOPED_PTR_VECTOR_H_ 6 #define CC_BASE_SCOPED_PTR_VECTOR_H_
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 DCHECK(!empty()); 65 DCHECK(!empty());
66 return at(size() - 1); 66 return at(size() - 1);
67 } 67 }
68 68
69 bool empty() const { 69 bool empty() const {
70 return data_.empty(); 70 return data_.empty();
71 } 71 }
72 72
73 scoped_ptr<T> take(iterator position) { 73 scoped_ptr<T> take(iterator position) {
74 if (position == end()) 74 if (position == end())
75 return scoped_ptr<T>(NULL); 75 return scoped_ptr<T>();
76 DCHECK(position < end()); 76 DCHECK(position < end());
77 77
78 typename std::vector<T*>::iterator writable_position = position; 78 typename std::vector<T*>::iterator writable_position = position;
79 scoped_ptr<T> ret(*writable_position); 79 scoped_ptr<T> ret(*writable_position);
80 *writable_position = NULL; 80 *writable_position = NULL;
81 return ret.Pass(); 81 return ret.Pass();
82 } 82 }
83 83
84 scoped_ptr<T> take_back() { 84 scoped_ptr<T> take_back() {
85 DCHECK(!empty()); 85 DCHECK(!empty());
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 171
172 private: 172 private:
173 std::vector<T*> data_; 173 std::vector<T*> data_;
174 174
175 DISALLOW_COPY_AND_ASSIGN(ScopedPtrVector); 175 DISALLOW_COPY_AND_ASSIGN(ScopedPtrVector);
176 }; 176 };
177 177
178 } // namespace cc 178 } // namespace cc
179 179
180 #endif // CC_BASE_SCOPED_PTR_VECTOR_H_ 180 #endif // CC_BASE_SCOPED_PTR_VECTOR_H_
OLDNEW
« no previous file with comments | « cc/base/scoped_ptr_hash_map.h ('k') | cc/layers/delegated_renderer_layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698