Flutter Engine
The Flutter Engine
|
#include <SkSpan_impl.h>
Public Member Functions | |
constexpr | SkSpan () |
template<typename Integer , std::enable_if_t< std::is_integral_v< Integer >, bool > = true> | |
constexpr | SkSpan (T *ptr, Integer size) |
template<typename U , typename = std::enable_if_t<std::is_same_v<const U, T>>> | |
constexpr | SkSpan (const SkSpan< U > &that) |
constexpr | SkSpan (const SkSpan &o)=default |
template<size_t N> | |
constexpr | SkSpan (T(&a)[N]) |
template<typename Container > | |
constexpr | SkSpan (Container &&c) |
SkSpan (std::initializer_list< T > il SK_CHECK_IL_LIFETIME) | |
constexpr SkSpan & | operator= (const SkSpan &that)=default |
constexpr T & | operator[] (size_t i) const |
constexpr T & | front () const |
constexpr T & | back () const |
constexpr T * | begin () const |
constexpr T * | end () const |
constexpr auto | rbegin () const |
constexpr auto | rend () const |
constexpr T * | data () const |
constexpr size_t | size () const |
constexpr bool | empty () const |
constexpr size_t | size_bytes () const |
constexpr SkSpan< T > | first (size_t prefixLen) const |
constexpr SkSpan< T > | last (size_t postfixLen) const |
constexpr SkSpan< T > | subspan (size_t offset) const |
constexpr SkSpan< T > | subspan (size_t offset, size_t count) const |
SkSpan holds a reference to contiguous data of type T along with a count. SkSpan does not own the data itself but is merely a reference, therefore you must take care with the lifetime of the underlying data.
SkSpan is a count and a pointer into existing array or data type that stores its data in contiguous memory like std::vector. Any container that works with std::size() and std::data() can be used.
SkSpan makes a convenient parameter for a routine to accept array like things. This allows you to write the routine without overloads for all different container types.
Example: void routine(SkSpan<const int> a) { ... }
std::vector v = {1, 2, 3, 4, 5};
routine(a);
A word of caution when working with initializer_list, initializer_lists have a lifetime that is limited to the current statement. The following is correct and safe:
Example: routine({1,2,3,4,5});
The following is undefined, and will result in erratic execution:
Bad Example: initializer_list l = {1, 2, 3, 4, 5}; // The data behind l dies at the ;. routine(l);
Definition at line 65 of file SkSpan_impl.h.
Definition at line 67 of file SkSpan_impl.h.
|
inlineconstexpr |
Definition at line 70 of file SkSpan_impl.h.
|
inlineconstexpr |
Definition at line 75 of file SkSpan_impl.h.
Definition at line 77 of file SkSpan_impl.h.
|
inlineconstexpr |
Definition at line 79 of file SkSpan_impl.h.
|
inline |
Definition at line 80 of file SkSpan_impl.h.
Definition at line 89 of file SkSpan_impl.h.
Definition at line 90 of file SkSpan_impl.h.
Definition at line 94 of file SkSpan_impl.h.
Definition at line 96 of file SkSpan_impl.h.
Definition at line 91 of file SkSpan_impl.h.
|
inlineconstexpr |
Definition at line 98 of file SkSpan_impl.h.
Definition at line 88 of file SkSpan_impl.h.
|
inlineconstexpr |
Definition at line 101 of file SkSpan_impl.h.
|
constexprdefault |
Definition at line 85 of file SkSpan_impl.h.
Definition at line 92 of file SkSpan_impl.h.
Definition at line 93 of file SkSpan_impl.h.
Definition at line 95 of file SkSpan_impl.h.
Definition at line 97 of file SkSpan_impl.h.
|
inlineconstexpr |
Definition at line 105 of file SkSpan_impl.h.
|
inlineconstexpr |
Definition at line 108 of file SkSpan_impl.h.