Template Class Span

Class Documentation

template<typename T>
class Span

Provides a non owning reference to a contiguous range of objects.

Param <T>

The type of object referenced

Public Functions

inline Span() = default

Constructs an instance of Span<>

inline Span(std::nullptr_t)

Constructs an instance of Span<>

inline Span(T &data)

Constructs an instance of Span<>

Parameters

data -- [in] A reference to the data to reference via this Span<>

inline Span(T *data, size_t count)

Constructs an instance of Span<>

Parameters
  • data -- [in] A pointer to the data to reference via this Span<>

  • count -- [in] The number of elements referenced via this Span<>

template<size_t Count>
inline Span(std::array<T, Count> &container)

Constructs an instance of Span<>

Parameters

container -- [in] A std::array<> containing the data to reference via this Span<>

inline Span(std::vector<T> &container)

Constructs an instance of Span<>

Parameters

container -- [in] A std::vector<> containing the data to reference via this Span<>

inline T const &operator[](size_t index) const

Gets a reference to the value at a given index.

Parameters

index -- [in] The index of the value to get

Returns

A reference to the value at the given index

inline T &operator[](size_t index)

Gets a reference to the value at a given index.

Parameters

index -- [in] The index of the value to get

Returns

A reference to the value at the given index

inline T const *begin() const

Gets a pointer to this Spans<>'s first element.

Returns

A pointer to this Spans<>'s first element

inline T *begin()

Gets a pointer to this Spans<>'s first element.

Returns

A pointer to this Spans<>'s first element

inline T const *end() const

Gets a pointer to this Spans<>'s last element.

Returns

A pointer to this Spans<>'s last element

inline T *end()

Gets a pointer to this Spans<>'s last element.

Returns

A pointer to this Spans<>'s last element

inline T const &front() const

Gets a reference to this Span<>'s first element.

Returns

A reference to this Span<>'s first element

inline T &front()

Gets a reference to this Span<>'s first element.

Returns

A reference to this Span<>'s first element

inline T const &back() const

Gets a reference to this Span<>'s last element.

Returns

A reference to this Span<>'s last element

inline T &back()

Gets a reference to this Span<>'s last element.

Returns

A reference to this Span<>'s last element

inline bool empty() const

Gets a value indicating whether or not this Span<> is empty.

Returns

A value indicating whether or not this Span<> is empty

inline size_t size() const

Gets the number of elements referenced by this Span<>

Returns

The number of elements referenced by this Span<>

inline size_t size_bytes() const

Gets the number of bytes referenced by this Span<>

Returns

The number of bytes referenced by this Span<>

inline void clear()

Clears this Span<>

inline T const *data() const

Gets a pointer to this Span<>'s referenced data.

Returns

A pointer to this Span<>'s referenced data

inline T *data()

Gets a pointer to this Span<>'s referenced data.

Returns

A pointer to this Span<>'s referenced data