Flutter Engine
The Flutter Engine
Classes | Namespaces | Typedefs | Functions
SkTemplates.h File Reference
#include "include/private/base/SkAlign.h"
#include "include/private/base/SkAssert.h"
#include "include/private/base/SkDebug.h"
#include "include/private/base/SkMalloc.h"
#include "include/private/base/SkTLogic.h"
#include "include/private/base/SkTo.h"
#include <array>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <memory>
#include <type_traits>
#include <utility>

Go to the source code of this file.

Classes

struct  SkOverloadedFunctionObject< T, P >
 
class  SkAutoTCallVProc< T, P >
 
class  skia_private::AutoTArray< T >
 
class  skia_private::AutoSTArray< kCountRequested, T >
 
class  skia_private::AutoTMalloc< T, typename >
 
class  skia_private::AutoSTMalloc< kCountRequested, T, typename >
 

Namespaces

namespace  skia_private
 

Typedefs

template<auto F>
using SkFunctionObject = SkOverloadedFunctionObject< std::remove_pointer_t< decltype(F)>, F >
 
using skia_private::UniqueVoidPtr = std::unique_ptr< void, SkOverloadedFunctionObject< void(void *), sk_free > >
 

Functions

template<typename T >
void sk_ignore_unused_variable (const T &)
 
template<typename T >
static T SkTAbs (T value)
 
template<typename D , typename S >
DSkTAfter (S *ptr, size_t count=1)
 
template<typename D , typename S >
DSkTAddOffset (S *ptr, ptrdiff_t byteOffset)
 
template<typename C , std::size_t... Is>
constexpr auto SkMakeArrayFromIndexSequence (C c, std::index_sequence< Is... > is) -> std::array< decltype(c(std::declval< typename decltype(is)::value_type >())), sizeof...(Is)>
 
template<size_t N, typename C >
constexpr auto SkMakeArray (C c) -> std::array< decltype(c(std::declval< typename std::index_sequence< N >::value_type >())), N >
 

Detailed Description

This file contains light-weight template classes for type-safe and exception-safe resource management.

Definition in file SkTemplates.h.

Typedef Documentation

◆ SkFunctionObject

template<auto F>
using SkFunctionObject = SkOverloadedFunctionObject<std::remove_pointer_t<decltype(F)>, F>

Definition at line 73 of file SkTemplates.h.

Function Documentation

◆ sk_ignore_unused_variable()

template<typename T >
void sk_ignore_unused_variable ( const T )
inline

Marks a local variable as known to be unused (to avoid warnings). Note that this does not prevent the local variable from being optimized away.

Definition at line 37 of file SkTemplates.h.

37{ }

◆ SkMakeArray()

template<size_t N, typename C >
constexpr auto SkMakeArray ( C  c) -> std::array<decltype(c(std::declval<typename std::index_sequence<N>::value_type>())), N>
constexpr

Definition at line 441 of file SkTemplates.h.

442 {
443 return SkMakeArrayFromIndexSequence(c, std::make_index_sequence<N>{});
444}
constexpr auto SkMakeArrayFromIndexSequence(C c, std::index_sequence< Is... > is) -> std::array< decltype(c(std::declval< typename decltype(is)::value_type >())), sizeof...(Is)>
Definition: SkTemplates.h:436

◆ SkMakeArrayFromIndexSequence()

template<typename C , std::size_t... Is>
constexpr auto SkMakeArrayFromIndexSequence ( C  c,
std::index_sequence< Is... >  is 
) -> std::array<decltype(c(std::declval<typename decltype(is)::value_type>())), sizeof...(Is)>
constexpr

Definition at line 436 of file SkTemplates.h.

437 {
438 return {{ c(Is)... }};
439}

◆ SkTAbs()

template<typename T >
static T SkTAbs ( T  value)
inlinestatic

This is a general purpose absolute-value function. See SkAbs32 in (SkSafe32.h) for a 32-bit int specific version that asserts.

Definition at line 43 of file SkTemplates.h.

43 {
44 if (value < 0) {
45 value = -value;
46 }
47 return value;
48}
uint8_t value

◆ SkTAddOffset()

template<typename D , typename S >
D * SkTAddOffset ( S *  ptr,
ptrdiff_t  byteOffset 
)
inline

Returns a pointer to a D which comes byteOffset bytes after S.

Definition at line 60 of file SkTemplates.h.

60 {
61 // The intermediate char* has the same cv-ness as D as this produces better error messages.
62 // This relies on the fact that reinterpret_cast can add constness, but cannot remove it.
63 return reinterpret_cast<D*>(reinterpret_cast<sknonstd::same_cv_t<char, D>*>(ptr) + byteOffset);
64}
typename same_cv< D, S >::type same_cv_t
Definition: SkTLogic.h:49

◆ SkTAfter()

template<typename D , typename S >
D * SkTAfter ( S *  ptr,
size_t  count = 1 
)
inline

Returns a pointer to a D which comes immediately after S[count].

Definition at line 53 of file SkTemplates.h.

53 {
54 return reinterpret_cast<D*>(ptr + count);
55}
int count
Definition: FontMgrTest.cpp:50