template<typename T, size_t Extent = -1>
stim::span class

A non-owning view of contiguous elements.

Template parameters
T The span's element type.
Extent The number of elements in the span (-1 == dynamic).

Public types

using const_pointer = const T*
Const-qualified pointer to a single element in the span.
using const_reference = const T&
Const-qualified reference to a single element in the span.
using difference_type = ptrdiff_t
The difference between two pointers.
using element_type = T
The span's element type.
using iterator = pointer
The iterator type returned by begin() and end().
using pointer = T*
Pointer to a single element in the span.
using reference = T&
Reference to a single element in the span.
using size_type = size_t
The unsigned integer type used for sizes, indices, et cetera.
using value_type = api_detail::remove_cv<T>
The span's element type without any cv-qualifiers.

Public static variables

static size_type extent constexpr
The maximal number of elements that can be represented by the span (-1 == dynamic).
static size_type stride constexpr
The size of a single element, in bytes.

Constructors, destructors, conversion operators

operator bool() const explicit constexpr noexcept
Returns true if the span's extent is greater than zero and the data pointer is not null.
operator span<const T, Extent>() const constexpr noexcept
Casts the span to the const equivalent.
span() defaulted constexpr noexcept
Default constructor.
span(const span&) defaulted constexpr noexcept
Copy constructor.
span(T* ptr, size_type count) constexpr noexcept
Pointer + count constructor.
template<size_type N>
span(T(&arr)[N]) constexpr noexcept
Array constructor.

Public functions

auto back() const -> reference constexpr noexcept
Returns a reference to the last element in the span.
auto begin() const -> iterator constexpr noexcept
Returns an iterator to the first element represented by the span.
auto data() const -> pointer constexpr noexcept
Returns a pointer to the first element represented by the span.
auto empty() const -> bool constexpr noexcept
Returns true if the span's extent is greater than zero.
auto end() const -> iterator constexpr noexcept
Returns an iterator to one-past-the-last element represented by the span.
auto front() const -> reference constexpr noexcept
Returns a reference to the first element in the span.
auto length() const -> size_type constexpr noexcept
Returns the number of elements represented by the span.
auto operator=(const span&) -> span& defaulted noexcept
Copy-assignment operator.
auto operator[](size_type idx) const -> reference constexpr noexcept
Returns a reference to an element in the span.
auto size() const -> size_type constexpr noexcept
Returns the number of elements represented by the span.
auto size_bytes() const -> size_type constexpr noexcept
Returns the size of the memory region represented by the span, in bytes.

Compatibility with UE4

template<typename Alloc>
span(::TArray<T, Alloc>& arr) noexcept
Constructs a span from a UE4 TArray.
template<typename SizeType>
span(const ::TArrayView<T, SizeType>& view) noexcept
Constructs a span from a UE4 TArrayView.

Typedef documentation

template<typename T, size_t Extent>
using stim::span<T, Extent>::const_reference = const T&

Const-qualified reference to a single element in the span.

template<typename T, size_t Extent>
using stim::span<T, Extent>::iterator = pointer

The iterator type returned by begin() and end().

template<typename T, size_t Extent>
using stim::span<T, Extent>::reference = T&

Reference to a single element in the span.

Function documentation

template<typename T, size_t Extent>
template<size_type N>
stim::span<T, Extent>::span(T(&arr)[N]) constexpr noexcept

Array constructor.

template<typename T, size_t Extent>
reference stim::span<T, Extent>::back() const constexpr noexcept

Returns a reference to the last element in the span.

template<typename T, size_t Extent>
iterator stim::span<T, Extent>::begin() const constexpr noexcept

Returns an iterator to the first element represented by the span.

template<typename T, size_t Extent>
iterator stim::span<T, Extent>::end() const constexpr noexcept

Returns an iterator to one-past-the-last element represented by the span.

template<typename T, size_t Extent>
reference stim::span<T, Extent>::front() const constexpr noexcept

Returns a reference to the first element in the span.

template<typename T, size_t Extent>
reference stim::span<T, Extent>::operator[](size_type idx) const constexpr noexcept

Returns a reference to an element in the span.

template<typename T, size_t Extent>
template<typename Alloc>
stim::span<T, Extent>::span(::TArray<T, Alloc>& arr) noexcept

Constructs a span from a UE4 TArray.

template<typename T, size_t Extent>
template<typename SizeType>
stim::span<T, Extent>::span(const ::TArrayView<T, SizeType>& view) noexcept

Constructs a span from a UE4 TArrayView.

Variable documentation

template<typename T, size_t Extent>
static size_type stim::span<T, Extent>::stride constexpr

The size of a single element, in bytes.