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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 /** | 149 /** |
150 * Version of above that uses a copy constructor to initialize the new item | 150 * Version of above that uses a copy constructor to initialize the new item |
151 */ | 151 */ |
152 T& push_back(const T& t) { | 152 T& push_back(const T& t) { |
153 T* newT = reinterpret_cast<T*>(this->push_back_raw(1)); | 153 T* newT = reinterpret_cast<T*>(this->push_back_raw(1)); |
154 new (newT) T(t); | 154 new (newT) T(t); |
155 return *newT; | 155 return *newT; |
156 } | 156 } |
157 | 157 |
158 /** | 158 /** |
| 159 * Version of above that uses a move constructor to initialize the new item |
| 160 */ |
| 161 T& push_back(T&& t) { |
| 162 T* newT = reinterpret_cast<T*>(this->push_back_raw(1)); |
| 163 new (newT) T(std::move(t)); |
| 164 return *newT; |
| 165 } |
| 166 |
| 167 /** |
159 * Construct a new T at the back of this array. | 168 * Construct a new T at the back of this array. |
160 */ | 169 */ |
161 template<class... Args> T& emplace_back(Args&&... args) { | 170 template<class... Args> T& emplace_back(Args&&... args) { |
162 T* newT = reinterpret_cast<T*>(this->push_back_raw(1)); | 171 T* newT = reinterpret_cast<T*>(this->push_back_raw(1)); |
163 return *new (newT) T(std::forward<Args>(args)...); | 172 return *new (newT) T(std::forward<Args>(args)...); |
164 } | 173 } |
165 | 174 |
166 /** | 175 /** |
167 * Allocates n more default-initialized T values, and returns the address of | 176 * Allocates n more default-initialized T values, and returns the address of |
168 * the start of that new range. Note: this address is only valid until the | 177 * the start of that new range. Note: this address is only valid until the |
(...skipping 337 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 |