| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 // Borrowed from Chromium's src/base/memory/scoped_vector.h. | 11 // Borrowed from Chromium's src/base/memory/scoped_vector.h. |
| 12 | 12 |
| 13 #ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_SCOPED_VECTOR_H_ | 13 #ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_SCOPED_VECTOR_H_ |
| 14 #define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_SCOPED_VECTOR_H_ | 14 #define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_SCOPED_VECTOR_H_ |
| 15 | 15 |
| 16 #include <vector> | 16 #include <vector> |
| 17 | 17 |
| 18 #include "webrtc/base/checks.h" | 18 #include "webrtc/base/checks.h" |
| 19 #include "webrtc/base/deprecation.h" | |
| 20 #include "webrtc/system_wrappers/include/stl_util.h" | 19 #include "webrtc/system_wrappers/include/stl_util.h" |
| 21 | 20 |
| 22 namespace webrtc { | 21 namespace webrtc { |
| 23 | 22 |
| 24 // ScopedVector wraps a vector deleting the elements from its | 23 // ScopedVector wraps a vector deleting the elements from its |
| 25 // destructor. | 24 // destructor. |
| 26 template <class T> | 25 template <class T> |
| 27 class ScopedVector { | 26 class ScopedVector { |
| 28 public: | 27 public: |
| 29 typedef typename std::vector<T*>::allocator_type allocator_type; | 28 typedef typename std::vector<T*>::allocator_type allocator_type; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 49 std::swap(v_, other.v_); // The arguments are std::vectors, so std::swap | 48 std::swap(v_, other.v_); // The arguments are std::vectors, so std::swap |
| 50 // is the one that we want. | 49 // is the one that we want. |
| 51 other.clear(); | 50 other.clear(); |
| 52 return *this; | 51 return *this; |
| 53 } | 52 } |
| 54 | 53 |
| 55 // Deleted copy constructor and copy assignment, to make the type move-only. | 54 // Deleted copy constructor and copy assignment, to make the type move-only. |
| 56 ScopedVector(const ScopedVector& other) = delete; | 55 ScopedVector(const ScopedVector& other) = delete; |
| 57 ScopedVector& operator=(const ScopedVector& other) = delete; | 56 ScopedVector& operator=(const ScopedVector& other) = delete; |
| 58 | 57 |
| 59 // Get an rvalue reference. (sv.Pass() does the same thing as std::move(sv).) | |
| 60 // Deprecated; remove in March 2016 (bug 5373). | |
| 61 RTC_DEPRECATED ScopedVector&& Pass() { return DEPRECATED_Pass(); } | |
| 62 ScopedVector&& DEPRECATED_Pass() { | |
| 63 return std::move(*this); | |
| 64 } | |
| 65 | |
| 66 reference operator[](size_t index) { return v_[index]; } | 58 reference operator[](size_t index) { return v_[index]; } |
| 67 const_reference operator[](size_t index) const { return v_[index]; } | 59 const_reference operator[](size_t index) const { return v_[index]; } |
| 68 | 60 |
| 69 bool empty() const { return v_.empty(); } | 61 bool empty() const { return v_.empty(); } |
| 70 size_t size() const { return v_.size(); } | 62 size_t size() const { return v_.size(); } |
| 71 | 63 |
| 72 reverse_iterator rbegin() { return v_.rbegin(); } | 64 reverse_iterator rbegin() { return v_.rbegin(); } |
| 73 const_reverse_iterator rbegin() const { return v_.rbegin(); } | 65 const_reverse_iterator rbegin() const { return v_.rbegin(); } |
| 74 reverse_iterator rend() { return v_.rend(); } | 66 reverse_iterator rend() { return v_.rend(); } |
| 75 const_reverse_iterator rend() const { return v_.rend(); } | 67 const_reverse_iterator rend() const { return v_.rend(); } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 return v_.erase(first, last); | 143 return v_.erase(first, last); |
| 152 } | 144 } |
| 153 | 145 |
| 154 private: | 146 private: |
| 155 std::vector<T*> v_; | 147 std::vector<T*> v_; |
| 156 }; | 148 }; |
| 157 | 149 |
| 158 } // namespace webrtc | 150 } // namespace webrtc |
| 159 | 151 |
| 160 #endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_SCOPED_VECTOR_H_ | 152 #endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_SCOPED_VECTOR_H_ |
| OLD | NEW |