View over a contiguous sequence of items (pointer + size in elements). More...
#include <Span.h>
Public Types | |
using | SizeType = size_t |
using | VoidType = typename TypeTraits::SameConstnessAs< Type, void >::type |
Public Member Functions | |
template<size_t N> | |
constexpr | Span (Type(&_items)[N]) |
constexpr | Span () |
Builds an empty Span. More... | |
constexpr | Span (Type *items, SizeType sizeInElements) |
Builds a Span from an array. More... | |
constexpr | Span (Type &type) |
Builds a Span from a single object. More... | |
constexpr | Span (std::initializer_list< Type > list) |
Span specialized constructor (mainly used for converting const char* to StringView) More... | |
operator Span< const Type > () const | |
Converts to a span with const qualified Type. More... | |
template<typename T > | |
Span< T > | reinterpret_as_array_of () const |
Reinterprets the current span as an array of the specified type. More... | |
constexpr const Type * | begin () const |
Returns pointer to first element of the span. More... | |
constexpr const Type * | end () const |
Returns pointer to one after the last element of the span. More... | |
constexpr const Type * | data () const |
Returns pointer to first element of the span. More... | |
constexpr Type * | begin () |
Returns pointer to first element of the span. More... | |
constexpr Type * | end () |
Returns pointer to one after the last element of the span. More... | |
constexpr Type * | data () |
Returns pointer to first element of the span. More... | |
constexpr SizeType | sizeInElements () const |
Size of Span in elements. More... | |
constexpr SizeType | sizeInBytes () const |
Size of Span in bytes. More... | |
constexpr bool | sliceStart (SizeType offsetInElements, Span &destination) const |
Creates another Span, starting at an offset in elements from current Span, until end. More... | |
constexpr bool | sliceStartLength (SizeType offsetInElements, SizeType lengthInElements, Span &destination) const |
Creates another Span, starting at an offset in elements from current Span of specified length. More... | |
const bool | sliceFromStartUntil (Span other, Span &output) const |
Creates another Span shorter or equal than the current one such that its end equals other.data(). More... | |
constexpr bool | empty () const |
Check if Span is empty. More... | |
constexpr bool | contains (const Type &type, SizeType *index=nullptr) const |
Type & | operator[] (SizeType idx) |
const Type & | operator[] (SizeType idx) const |
template<typename IntType > | |
Type * | get (IntType idx) |
Gets the item at given index or nullptr if index is negative or bigger than size. More... | |
template<typename IntType > | |
const Type * | get (IntType idx) const |
Gets the item at given index or nullptr if index is negative or bigger than size. More... | |
template<typename U > | |
bool | equals (const Span< U > other) const |
Static Public Member Functions | |
template<typename T > | |
static Span< Type > | reinterpret_object (T &value) |
Constructs a Span reinterpreting memory pointed by object of type T as a type Type More... | |
static Span< Type > | reinterpret_bytes (VoidType *rawMemory, SizeType sizeInBytes) |
Construct a span reinterpreting raw memory (void* or const void* ) to Type or const Type More... | |
View over a contiguous sequence of items (pointer + size in elements).
Type | Any type |
|
inlineconstexpr |
Builds a Span from an array.
items | pointer to the first member of the array |
sizeInElements | number of elements in in the array |
Builds a Span from a single object.
type | A reference to a single object of type Type |
|
inlineconstexpr |
Span specialized constructor (mainly used for converting const char* to StringView)
list | an initializer list of elements |
|
inlineconstexpr |
Returns pointer to first element of the span.
|
inlineconstexpr |
Returns pointer to first element of the span.
|
inlineconstexpr |
Returns pointer to first element of the span.
|
inlineconstexpr |
Returns pointer to first element of the span.
|
inlineconstexpr |
|
inlineconstexpr |
Returns pointer to one after the last element of the span.
|
inlineconstexpr |
Returns pointer to one after the last element of the span.
|
inline |
Gets the item at given index or nullptr if index is negative or bigger than size.
|
inline |
Gets the item at given index or nullptr if index is negative or bigger than size.
Converts to a span with const
qualified Type.
|
inline |
Reinterprets the current span as an array of the specified type.
|
inlinestatic |
Construct a span reinterpreting raw memory (void*
or const void*
) to Type
or const Type
rawMemory | Pointer to raw buffer of memory |
sizeInBytes | Size of the raw buffer in Bytes |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
Creates another Span, starting at an offset in elements from current Span, until end.
offsetInElements | Offset in current Span where destination Span will be starting |
destination | Reference to a Span that will hold the resulting computed span |
true
if destination has been written.false
if offsetInElements is bigger to than Span::size().
|
inlineconstexpr |
Creates another Span, starting at an offset in elements from current Span of specified length.
offsetInElements | Offset in current Span where destination Span will be starting |
lengthInElements | Number of elements wanted for destination Span |
destination | Reference to a Span that will hold the resulting computed span |
true
if destination has been written.false
if (offsetInElements + lengthInElements) is bigger to than Span::size().