#include <bn_span.h>
template<typename Type>
bn::span class

Refers to a contiguous sequence of elements with the first element of the sequence at position zero.

Template parameters
Type Element type.

The elements are not copied but referenced, so they should outlive the span to avoid dangling references.

Public types

using value_type = Type
Value type alias.
using size_type = int
Size type alias.
using difference_type = int
Difference type alias.
using reference = Type&
Reference alias.
using const_reference = const Type&
Const reference alias.
using pointer = Type*
Pointer alias.
using const_pointer = const Type*
Const pointer alias.
using iterator = Type*
Iterator alias.
using const_iterator = const Type*
Const iterator alias.
using reverse_iterator = bn::reverse_iterator<iterator>
Reverse iterator alias.
using const_reverse_iterator = bn::reverse_iterator<const_iterator>
Const reverse iterator alias.

Constructors, destructors, conversion operators

span() defaulted constexpr
Constructs an empty span.
span(pointer ptr, size_type size) constexpr
Constructs a span that is a view over the range [ptr, ptr + size).
span(pointer first, pointer last) constexpr
Constructs a span that is a view over the range [first, last).
template<size_type ArraySize>
span(value_type(&array)[ArraySize]) constexpr
Constructs a span that is a view over the given array.
template<class OtherType, size_type ArraySize>
span(const array<OtherType, ArraySize>& array) constexpr
Constructs a span that is a const view over the given bn::array.
template<class OtherType, size_type ArraySize>
span(array<OtherType, ArraySize>& array) constexpr
Constructs a span that is a non-const view over the given bn::array.
template<class OtherType>
span(const span<OtherType>& other) constexpr
Constructs a span that is a view over a span of another type.

Public functions

auto data() const -> const_pointer constexpr
Returns a const pointer to the beginning of the referenced data.
auto data() -> pointer constexpr
Returns a pointer to the beginning of the referenced data.
auto size() const -> size_type constexpr
Returns the number of referenced elements.
auto size_bytes() const -> size_type constexpr
Returns the number of referenced bytes.
auto empty() const -> bool constexpr
Indicates if it doesn't reference any element.
auto begin() const -> const_iterator constexpr
Returns a const iterator to the beginning of the span.
auto begin() -> iterator constexpr
Returns an iterator to the beginning of the span.
auto cbegin() const -> const_iterator constexpr
Returns a const iterator to the beginning of the span.
auto end() const -> const_iterator constexpr
Returns a const iterator to the end of the span.
auto end() -> iterator constexpr
Returns an iterator to the end of the span.
auto cend() const -> const_iterator constexpr
Returns a const iterator to the end of the span.
auto rbegin() const -> const_reverse_iterator constexpr
Returns a const reverse iterator to the end of the span.
auto rbegin() -> reverse_iterator constexpr
Returns a reverse iterator to the end of the span.
auto crbegin() const -> const_reverse_iterator constexpr
Returns a const reverse iterator to the end of the span.
auto rend() const -> const_reverse_iterator constexpr
Returns a const reverse iterator to the begin of the span.
auto rend() -> reverse_iterator constexpr
Returns a reverse iterator to the begin of the span.
auto crend() const -> const_reverse_iterator constexpr
Returns a const reverse iterator to the begin of the span.
auto front() const -> const_reference constexpr
Returns a const reference to the first element.
auto front() -> reference constexpr
Returns a reference to the first element.
auto back() const -> const_reference constexpr
Returns a const reference to the last element.
auto back() -> reference constexpr
Returns a reference to the last element.
auto operator[](size_type index) const -> const_reference constexpr
Returns a const reference to the value stored at the specified index.
auto operator[](size_type index) -> reference constexpr
Returns a reference to the value stored at the specified index.
auto at(size_type index) const -> const_reference constexpr
Returns a const reference to the value stored at the specified index.
auto at(size_type index) -> reference constexpr
Returns a reference to the value stored at the specified index.
auto first(size_type count) const -> span constexpr
Returns a span that is a view over the first count elements of this span.
auto last(size_type count) const -> span constexpr
Returns a span that is a view over the last count elements of this span.
auto subspan(size_type offset) const -> span constexpr
Returns a span that is a view over the elements of this span starting at offset.
auto subspan(size_type offset, size_type count) const -> span constexpr
Obtains a span that is a view over the count elements of this span starting at offset.
void swap(span& other) constexpr
Exchanges the contents of this span with those of the other one.

Friends

auto swap(span& a, span& b) -> friend void constexpr
Exchanges the contents of a span with those of another one.
auto operator==(const span& a, const span& b) -> friend bool constexpr
Equal operator.
auto operator!=(const span& a, const span& b) -> friend bool constexpr
Not equal operator.
auto operator<(const span& a, const span& b) -> friend bool constexpr
Less than operator.
auto operator>(const span& a, const span& b) -> friend bool constexpr
Greater than operator.
auto operator<=(const span& a, const span& b) -> friend bool constexpr
Less than or equal operator.
auto operator>=(const span& a, const span& b) -> friend bool constexpr
Greater than or equal operator.

Function documentation

template<typename Type>
bn::span<Type>::span(pointer ptr, size_type size) constexpr

Constructs a span that is a view over the range [ptr, ptr + size).

Parameters
ptr Pointer to the first element.
size Elements count.

template<typename Type>
bn::span<Type>::span(pointer first, pointer last) constexpr

Constructs a span that is a view over the range [first, last).

Parameters
first Pointer to the first element.
last Pointer to the element after the last.

template<typename Type>
void bn::span<Type>::swap(span& other) constexpr

Exchanges the contents of this span with those of the other one.

Parameters
other span to exchange the contents with.

template<typename Type>
friend void swap(span& a, span& b) constexpr

Exchanges the contents of a span with those of another one.

Parameters
a First span to exchange the contents with.
b Second span to exchange the contents with.

template<typename Type>
friend bool operator==(const span& a, const span& b) constexpr

Equal operator.

Parameters
a First span to compare.
b Second span to compare.
Returns true if the first span is equal to the second one, otherwise false.

template<typename Type>
friend bool operator!=(const span& a, const span& b) constexpr

Not equal operator.

Parameters
a First span to compare.
b Second span to compare.
Returns true if the first span is not equal to the second one, otherwise false.

template<typename Type>
friend bool operator<(const span& a, const span& b) constexpr

Less than operator.

Parameters
a First span to compare.
b Second span to compare.
Returns true if the first span is lexicographically less than the second one, otherwise false.

template<typename Type>
friend bool operator>(const span& a, const span& b) constexpr

Greater than operator.

Parameters
a First span to compare.
b Second span to compare.
Returns true if the first span is lexicographically greater than the second one, otherwise false.

template<typename Type>
friend bool operator<=(const span& a, const span& b) constexpr

Less than or equal operator.

Parameters
a First span to compare.
b Second span to compare.
Returns true if the first span is lexicographically less than or equal to the second one, otherwise false.

template<typename Type>
friend bool operator>=(const span& a, const span& b) constexpr

Greater than or equal operator.

Parameters
a First span to compare.
b Second span to compare.
Returns true if the first span is lexicographically greater than or equal to the second one, otherwise false.