Sane C++ Libraries
C++ Platform Abstraction Libraries
Loading...
Searching...
No Matches
SC::Span< Type > Struct Template Reference

View over a contiguous sequence of items (pointer + size in elements). More...

#include <Span.h>

Public Member Functions

template<size_t N, typename U = Type, EnableNotVoid< U > = true>
constexpr Span (U(&itemsArray)[N])
 
constexpr Span ()
 Builds an empty Span.
 
constexpr Span (Type *items, SizeType sizeInElements)
 Builds a Span from an array.
 
template<typename U = Type>
constexpr Span (TypeIfNotVoid< U > &type)
 Builds a Span from a single object.
 
template<typename U = Type>
constexpr Span (std::initializer_list< TypeIfNotVoid< U > > list)
 Span specialized constructor (mainly used for converting const char* to StringView)
 
template<typename U = Type>
 operator Span< const TypeIfNotVoid< U > > () const
 
template<typename U = Type>
 operator Span< TypeIfNotVoid< U > > ()
 
 operator Span< const void > () const
 
 operator Span< void > ()
 
template<typename T >
Span< const T > reinterpret_as_span_of () const
 Reinterprets the current span as an array of the specified type.
 
template<typename T >
Span< T > reinterpret_as_span_of ()
 Reinterprets the current span as an array of the specified type.
 
template<typename T >
T * start_lifetime_as_array () const noexcept
 
template<typename T >
T * start_lifetime_as_array () noexcept
 
template<typename T >
const T * start_lifetime_as () const noexcept
 
template<typename T >
T * start_lifetime_as () noexcept
 
constexpr const Type * begin () const
 
constexpr const Type * end () const
 
constexpr const Type * data () const
 
constexpr Type * begin ()
 
constexpr Type * end ()
 
constexpr Type * data ()
 
constexpr SizeType sizeInElements () const
 
constexpr SizeType sizeInBytes () const
 
constexpr bool empty () const
 
template<typename U = Type>
TypeIfNotVoid< U > & operator[] (SizeType idx)
 
template<typename U = Type>
const TypeIfNotVoid< U > & operator[] (SizeType idx) const
 
constexpr bool sliceStart (SizeType offsetInElements, Span &destination) const
 Creates another Span, starting at an offset in elements from current Span, until end.
 
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.
 

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
 
static Span< Type > reinterpret_bytes (VoidType *rawMemory, SizeType sizeInBytes)
 Construct a span reinterpreting raw memory (void* or const void*) to Type or const Type
 

Detailed Description

template<typename Type>
struct SC::Span< Type >

View over a contiguous sequence of items (pointer + size in elements).

Template Parameters
TypeAny type

Constructor & Destructor Documentation

◆ Span() [1/4]

template<typename Type >
SC::Span< Type >::Span ( )
inlineconstexpr

Builds an empty Span.

◆ Span() [2/4]

template<typename Type >
SC::Span< Type >::Span ( Type * items,
SizeType sizeInElements )
inlineconstexpr

Builds a Span from an array.

Parameters
itemspointer to the first member of the array
sizeInElementsnumber of elements in in the array

◆ Span() [3/4]

template<typename Type >
template<typename U = Type>
SC::Span< Type >::Span ( TypeIfNotVoid< U > & type)
inlineconstexpr

Builds a Span from a single object.

Parameters
typeA reference to a single object of type Type

◆ Span() [4/4]

template<typename Type >
template<typename U = Type>
SC::Span< Type >::Span ( std::initializer_list< TypeIfNotVoid< U > > list)
inlineconstexpr

Span specialized constructor (mainly used for converting const char* to StringView)

Parameters
listan initializer list of elements

Member Function Documentation

◆ reinterpret_as_span_of() [1/2]

template<typename Type >
template<typename T >
Span< T > SC::Span< Type >::reinterpret_as_span_of ( )
inlinenodiscard

Reinterprets the current span as an array of the specified type.

◆ reinterpret_as_span_of() [2/2]

template<typename Type >
template<typename T >
Span< const T > SC::Span< Type >::reinterpret_as_span_of ( ) const
inlinenodiscard

Reinterprets the current span as an array of the specified type.

◆ reinterpret_bytes()

template<typename Type >
static Span< Type > SC::Span< Type >::reinterpret_bytes ( VoidType * rawMemory,
SizeType sizeInBytes )
inlinestaticnodiscard

Construct a span reinterpreting raw memory (void* or const void*) to Type or const Type

Parameters
rawMemoryPointer to raw buffer of memory
sizeInBytesSize of the raw buffer in Bytes
Returns
The reinterpreted Span object

◆ reinterpret_object()

template<typename Type >
template<typename T >
static Span< Type > SC::Span< Type >::reinterpret_object ( T & value)
inlinestaticnodiscard

Constructs a Span reinterpreting memory pointed by object of type T as a type Type

Template Parameters
TType of object to be reinterpreted
Parameters
valueThe source object to be reinterpreted
Returns
The output converted Span object

◆ sliceStart()

template<typename Type >
bool SC::Span< Type >::sliceStart ( SizeType offsetInElements,
Span< Type > & destination ) const
inlinenodiscardconstexpr

Creates another Span, starting at an offset in elements from current Span, until end.

Parameters
offsetInElementsOffset in current Span where destination Span will be starting
destinationReference to a Span that will hold the resulting computed span
Returns
  • true if destination has been written.
  • false if offsetInElements is bigger to than Span::size().

◆ sliceStartLength()

template<typename Type >
bool SC::Span< Type >::sliceStartLength ( SizeType offsetInElements,
SizeType lengthInElements,
Span< Type > & destination ) const
inlinenodiscardconstexpr

Creates another Span, starting at an offset in elements from current Span of specified length.

Parameters
offsetInElementsOffset in current Span where destination Span will be starting
lengthInElementsNumber of elements wanted for destination Span
destinationReference to a Span that will hold the resulting computed span
Returns
  • true if destination has been written.
  • false if (offsetInElements + lengthInElements) is bigger to than Span::size().

The documentation for this struct was generated from the following file: