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 |
11 #include "../private/SkTemplates.h" | 11 #include "../private/SkTemplates.h" |
12 #include "SkTypes.h" | 12 #include "SkTypes.h" |
13 | 13 |
14 #include <new> | 14 #include <new> |
| 15 #include <utility> |
15 | 16 |
16 template <typename T, bool MEM_COPY = false> class SkTArray; | 17 template <typename T, bool MEM_COPY = false> class SkTArray; |
17 | 18 |
18 namespace SkTArrayExt { | 19 namespace SkTArrayExt { |
19 | 20 |
20 template<typename T> | 21 template<typename T> |
21 inline void copy(SkTArray<T, true>* self, int dst, int src) { | 22 inline void copy(SkTArray<T, true>* self, int dst, int src) { |
22 memcpy(&self->fItemArray[dst], &self->fItemArray[src], sizeof(T)); | 23 memcpy(&self->fItemArray[dst], &self->fItemArray[src], sizeof(T)); |
23 } | 24 } |
24 template<typename T> | 25 template<typename T> |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 T* newT = reinterpret_cast<T*>(this->push_back_raw(1)); | 192 T* newT = reinterpret_cast<T*>(this->push_back_raw(1)); |
192 new (newT) T(t); | 193 new (newT) T(t); |
193 return *newT; | 194 return *newT; |
194 } | 195 } |
195 | 196 |
196 /** | 197 /** |
197 * Construct a new T at the back of this array. | 198 * Construct a new T at the back of this array. |
198 */ | 199 */ |
199 template<class... Args> T& emplace_back(Args&&... args) { | 200 template<class... Args> T& emplace_back(Args&&... args) { |
200 T* newT = reinterpret_cast<T*>(this->push_back_raw(1)); | 201 T* newT = reinterpret_cast<T*>(this->push_back_raw(1)); |
201 return *new (newT) T(skstd::forward<Args>(args)...); | 202 return *new (newT) T(std::forward<Args>(args)...); |
202 } | 203 } |
203 | 204 |
204 /** | 205 /** |
205 * Allocates n more default-initialized T values, and returns the address of | 206 * Allocates n more default-initialized T values, and returns the address of |
206 * the start of that new range. Note: this address is only valid until the | 207 * the start of that new range. Note: this address is only valid until the |
207 * next API call made on the array that might add or remove elements. | 208 * next API call made on the array that might add or remove elements. |
208 */ | 209 */ |
209 T* push_back_n(int n) { | 210 T* push_back_n(int n) { |
210 SkASSERT(n >= 0); | 211 SkASSERT(n >= 0); |
211 T* newTs = reinterpret_cast<T*>(this->push_back_raw(n)); | 212 T* newTs = reinterpret_cast<T*>(this->push_back_raw(n)); |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 SkSTArray& operator= (const INHERITED& array) { | 550 SkSTArray& operator= (const INHERITED& array) { |
550 INHERITED::operator=(array); | 551 INHERITED::operator=(array); |
551 return *this; | 552 return *this; |
552 } | 553 } |
553 | 554 |
554 private: | 555 private: |
555 SkAlignedSTStorage<N,T> fStorage; | 556 SkAlignedSTStorage<N,T> fStorage; |
556 }; | 557 }; |
557 | 558 |
558 #endif | 559 #endif |
OLD | NEW |