8#ifndef SkTemplates_DEFINED
9#define SkTemplates_DEFINED
54 return reinterpret_cast<D*
>(ptr +
count);
60template <
typename D,
typename S>
inline D*
SkTAddOffset(
S* ptr, ptrdiff_t byteOffset) {
67 template <
typename... Args>
69 return P(std::forward<Args>(
args)...);
85 :
public std::unique_ptr<T, SkFunctionObject<P>> {
86 using inherited = std::unique_ptr<T, SkFunctionObject<P>>;
88 using inherited::inherited;
92 operator T*()
const {
return this->
get(); }
104 fSize = check_size_bytes_too_big<T>(
size);
105 fData.reset(
size > 0 ?
new T[
size] :
nullptr);
112 fSize = std::exchange(other.fSize, 0);
115 if (
this != &other) {
116 fData = std::move(other.fData);
117 fSize = std::exchange(other.fSize, 0);
127 T*
get()
const {
return fData.get(); }
133 const T*
data()
const {
return fData.get(); }
136 size_t size()
const {
return fSize; }
137 bool empty()
const {
return fSize == 0; }
150 if (fData ==
nullptr) {
153 return fData + fSize;
156 if (fData ==
nullptr) {
159 return fData + fSize;
163 std::unique_ptr<T[]> fData;
198 while (iter >
start) {
203 if (fCount !=
count) {
204 if (fCount > kCount) {
210 if (
count > kCount) {
212 }
else if (
count > 0) {
213 fArray = (
T*) fStorage;
223 while (iter < stop) {
230 int count()
const {
return fCount; }
234 T*
get()
const {
return fArray; }
238 const T*
begin()
const {
return fArray; }
240 T*
end() {
return fArray + fCount; }
242 const T*
end()
const {
return fArray + fCount; }
251 const T*
data()
const {
return fArray; }
253 size_t size()
const {
return fCount; }
256#if defined(SK_BUILD_FOR_GOOGLE3)
259 static const int kMaxBytes = 4 * 1024;
260 static const int kCount = kCountRequested *
sizeof(
T) > kMaxBytes
261 ? kMaxBytes /
sizeof(
T)
264 static const int kCount = kCountRequested;
269 alignas(
T)
char fStorage[kCount *
sizeof(
T)];
301 T*
get()
const {
return fPtr.get(); }
303 operator T*() {
return fPtr.get(); }
305 operator const T*()
const {
return fPtr.get(); }
309 const T&
operator[](
int index)
const {
return fPtr.get()[index]; }
312 const T*
data()
const {
return fPtr.get(); }
326template <
size_t kCountRequested,
335 if (
count > kCount) {
360 if (
count > kCount) {
370 T*
get()
const {
return fPtr; }
376 operator const T*()
const {
389 const T*
data()
const {
return fPtr; }
394 if (
count > kCount) {
397 memcpy((
void*)fPtr,
fTStorage, kCount *
sizeof(
T));
412 static const size_t kCountWithPadding =
SkAlign4(kCountRequested*
sizeof(
T)) /
sizeof(
T);
413#if defined(SK_BUILD_FOR_GOOGLE3)
416 static const size_t kMaxBytes = 4 * 1024;
417 static const size_t kCount = kCountRequested *
sizeof(
T) > kMaxBytes
418 ? kMaxBytes /
sizeof(
T)
421 static const size_t kCount = kCountWithPadding;
435template<
typename C, std::size_t... Is>
437-> std::array<decltype(c(std::declval<typename decltype(is)::value_type>())),
sizeof...(Is)> {
438 return {{ c(Is)... }};
442-> std::array<
decltype(c(std::declval<
typename std::index_sequence<N>::value_type>())),
N> {
static constexpr T SkAlign4(T x)
SK_API T sk_collection_check_bounds(T i, T size)
SK_API void sk_free(void *)
static void * sk_malloc_throw(size_t size)
SK_API void * sk_realloc_throw(void *buffer, size_t size)
constexpr auto SkMakeArray(C c) -> std::array< decltype(c(std::declval< typename std::index_sequence< N >::value_type >())), N >
constexpr auto SkMakeArrayFromIndexSequence(C c, std::index_sequence< Is... > is) -> std::array< decltype(c(std::declval< typename decltype(is)::value_type >())), sizeof...(Is)>
void sk_ignore_unused_variable(const T &)
D * SkTAfter(S *ptr, size_t count=1)
D * SkTAddOffset(S *ptr, ptrdiff_t byteOffset)
constexpr size_t SkToSizeT(S x)
SkAutoTCallVProc(SkAutoTCallVProc &&that)
SkAutoTCallVProc(const SkAutoTCallVProc &)=delete
AutoSTArray(const AutoSTArray &)=delete
T & operator[](int index) const
AutoSTArray & operator=(const AutoSTArray &)=delete
AutoSTArray & operator=(AutoSTArray &&)=delete
AutoSTArray(AutoSTArray &&)=delete
AutoSTMalloc(size_t count)
AutoSTMalloc(AutoSTMalloc &&)=delete
const T & operator[](int index) const
AutoSTMalloc & operator=(AutoSTMalloc &&)=delete
AutoSTMalloc & operator=(const AutoSTMalloc &)=delete
void realloc(size_t count)
AutoSTMalloc(const AutoSTMalloc &)=delete
T & operator[](int index)
uint32_t fStorage32[SkAlign4(kCount *sizeof(T)) > > 2]
void reset(size_t count=0)
T & operator[](size_t index) const
size_t size_bytes() const
AutoTArray & operator=(AutoTArray &&other)
AutoTArray(AutoTArray &&other)
void realloc(size_t count)
AutoTMalloc(AutoTMalloc &&)=default
const T & operator[](int index) const
AutoTMalloc & operator=(AutoTMalloc &&)=default
T * reset(size_t count=0)
T & operator[](int index)
AutoTMalloc(T *ptr=nullptr)
AutoTMalloc(size_t count)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
const myers::Point & get(const myers::Segment &)
std::unique_ptr< void, SkOverloadedFunctionObject< void(void *), sk_free > > UniqueVoidPtr
typename same_cv< D, S >::type same_cv_t
auto operator()(Args &&... args) const -> decltype(P(std::forward< Args >(args)...))