Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkTArray_DEFINED | 8 #ifndef SkTArray_DEFINED |
| 9 #define SkTArray_DEFINED | 9 #define SkTArray_DEFINED |
| 10 | 10 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 * the reference only remains valid until the next call that adds or removes | 140 * the reference only remains valid until the next call that adds or removes |
| 141 * elements. | 141 * elements. |
| 142 */ | 142 */ |
| 143 T& push_back() { | 143 T& push_back() { |
| 144 T* newT = reinterpret_cast<T*>(this->push_back_raw(1)); | 144 T* newT = reinterpret_cast<T*>(this->push_back_raw(1)); |
| 145 new (newT) T; | 145 new (newT) T; |
| 146 return *newT; | 146 return *newT; |
| 147 } | 147 } |
| 148 | 148 |
| 149 /** | 149 /** |
| 150 * Version of above that uses a move constructor to initialize the new item | |
|
bungeman-skia
2016/03/04 19:36:33
This says 'above' but the copy push_back is below.
| |
| 151 */ | |
| 152 T& push_back(T&& t) { | |
| 153 T* newT = reinterpret_cast<T*>(this->push_back_raw(1)); | |
| 154 new (newT) T(std::move(t)); | |
| 155 return *newT; | |
| 156 } | |
| 157 | |
| 158 /** | |
| 150 * Version of above that uses a copy constructor to initialize the new item | 159 * Version of above that uses a copy constructor to initialize the new item |
| 151 */ | 160 */ |
| 152 T& push_back(const T& t) { | 161 T& push_back(const T& t) { |
| 153 T* newT = reinterpret_cast<T*>(this->push_back_raw(1)); | 162 T* newT = reinterpret_cast<T*>(this->push_back_raw(1)); |
| 154 new (newT) T(t); | 163 new (newT) T(t); |
| 155 return *newT; | 164 return *newT; |
| 156 } | 165 } |
| 157 | 166 |
| 158 /** | 167 /** |
| 159 * Construct a new T at the back of this array. | 168 * Construct a new T at the back of this array. |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 506 SkSTArray& operator= (const INHERITED& array) { | 515 SkSTArray& operator= (const INHERITED& array) { |
| 507 INHERITED::operator=(array); | 516 INHERITED::operator=(array); |
| 508 return *this; | 517 return *this; |
| 509 } | 518 } |
| 510 | 519 |
| 511 private: | 520 private: |
| 512 SkAlignedSTStorage<N,T> fStorage; | 521 SkAlignedSTStorage<N,T> fStorage; |
| 513 }; | 522 }; |
| 514 | 523 |
| 515 #endif | 524 #endif |
| OLD | NEW |