tetl 0.1.0
Embedded Template Library
|
A non-owning view over a contiguous sequence of objects. More...
#include <span.hpp>
Public Types | |
using | const_pointer = T const * |
using | const_reference = T const & |
using | difference_type = etl::ptrdiff_t |
using | element_type = T |
using | iterator = T * |
using | pointer = T * |
using | reference = T & |
using | reverse_iterator = etl::reverse_iterator< iterator > |
using | size_type = etl::size_t |
using | value_type = etl::remove_cv_t< T > |
Public Member Functions | |
constexpr | span () noexcept=default |
Constructs a span. Constructs an empty span whose data() == nullptr and size() == 0. | |
constexpr auto | back () const -> reference |
Returns a reference to the last element in the span. Calling front on an empty span results in undefined behavior. | |
constexpr auto | begin () const noexcept -> iterator |
Returns an iterator to the first element of the span. If the span is empty, the returned iterator will be equal to end(). | |
constexpr auto | data () const noexcept -> pointer |
Returns a pointer to the beginning of the sequence. | |
constexpr auto | empty () const noexcept -> bool |
Checks if the span is empty. | |
constexpr auto | end () const noexcept -> iterator |
Returns an iterator to the element following the last element of the span. This element acts as a placeholder; attempting to access it results in undefined behavior. | |
template<typename It > requires detail::span_convertible_from<remove_reference_t<iter_reference_t<It>>, T> | |
explicit (extent !=dynamic_extent) const expr span(It first | |
Constructs a span. | |
template<size_t Count> | |
constexpr auto | first () const -> span< element_type, Count > |
Obtains a span that is a view over the first Count elements of this span. The program is ill-formed if Count > Extent. | |
constexpr auto | first (size_type count) const -> span< element_type, dynamic_extent > |
Obtains a span that is a view over the first Count elements of this span. The behavior is undefined if Count > size(). | |
constexpr auto | front () const -> reference |
Returns a reference to the first element in the span. Calling front on an empty span results in undefined behavior. | |
template<size_t Count> | |
constexpr auto | last () const -> span< element_type, Count > |
Obtains a span that is a view over the last Count elements of this span. The program is ill-formed if Count > Extent. | |
constexpr auto | last (size_type count) const -> span< element_type, dynamic_extent > |
Obtains a span that is a view over the last Count elements of this span. The behavior is undefined if Count > size(). | |
constexpr auto | operator[] (size_type idx) const -> reference |
Returns a reference to the idx-th element of the sequence. The behavior is undefined if idx is out of range (i.e., if it is greater than or equal to size()). | |
constexpr auto | rbegin () const noexcept -> reverse_iterator |
Returns a reverse iterator to the first element of the reversed span. It corresponds to the last element of the non-reversed span. If the span is empty, the returned iterator is equal to rend(). | |
constexpr auto | rend () const noexcept -> reverse_iterator |
Returns a reverse iterator to the element following the last element of the reversed span. It corresponds to the element preceding the first element of the non-reversed span. This element acts as a placeholder, attempting to access it results in undefined behavior. | |
constexpr auto | size () const noexcept -> size_type |
Returns the number of elements in the span. | |
constexpr auto | size_bytes () const noexcept -> size_type |
Returns the number of elements in the span. | |
template<size_t Offset, size_t Count = dynamic_extent> | |
constexpr auto | subspan () const -> span< T, detail::subspan_extent< Offset, Count, Extent >()> |
Obtains a span that is a view over the Count elements of this span starting at offset Offset. If Count is etl::dynamic_extent, the number of elements in the subspan is size() - offset (i.e., it ends at the end of *this.). | |
constexpr auto | subspan (size_type offset, size_type count=dynamic_extent) const -> span< T, dynamic_extent > |
Obtains a span that is a view over the Count elements of this span starting at offset Offset. If Count is etl::dynamic_extent, the number of elements in the subspan is size() - offset (i.e., it ends at the end of *this.). | |
Public Attributes | |
size_type | count: _storage{first |
Static Public Attributes | |
static constexpr size_type | extent = Extent |
The number of elements in the sequence, or etl::dynamic_extent if dynamic. | |
Related Symbols | |
(Note that these are not member symbols.) | |
template<typename T , size_t N> | |
auto | as_bytes (span< T, N > s) noexcept -> span< byte const, detail::span_as_bytes_size< T, N > > |
Obtains a view to the object representation of the elements of the span s. | |
template<typename T , size_t N> | |
auto | as_writable_bytes (span< T, N > s) noexcept -> span< byte, detail::span_as_bytes_size< T, N > > |
Obtains a view to the object representation of the elements of the span s. | |
A non-owning view over a contiguous sequence of objects.
The class template span describes an object that can refer to a contiguous sequence of objects with the first element of the sequence at position zero. A span can either have a static extent, in which case the number of elements in the sequence is known and encoded in the type, or a dynamic extent.
If a span has dynamic extent a typical implementation holds two members: a pointer to T and a size. A span with static extent may have only one member: a pointer to T.
Constructs a span. Constructs an empty span whose data() == nullptr and size() == 0.
This overload only participates in overload resolution if extent == 0 || extent == etl::dynamic_extent.
Returns a reference to the last element in the span. Calling front on an empty span results in undefined behavior.
Returns an iterator to the first element of the span. If the span is empty, the returned iterator will be equal to end().
Returns a pointer to the beginning of the sequence.
Checks if the span is empty.
Returns an iterator to the element following the last element of the span. This element acts as a placeholder; attempting to access it results in undefined behavior.
explicit | ( | extent ! | = dynamic_extent | ) | const |
Constructs a span.
Constructs a span that is a view over the range [first, first + count);
Obtains a span that is a view over the first Count elements of this span. The program is ill-formed if Count > Extent.
|
inlineconstexpr |
Obtains a span that is a view over the first Count elements of this span. The behavior is undefined if Count > size().
Returns a reference to the first element in the span. Calling front on an empty span results in undefined behavior.
Obtains a span that is a view over the last Count elements of this span. The program is ill-formed if Count > Extent.
|
inlineconstexpr |
Obtains a span that is a view over the last Count elements of this span. The behavior is undefined if Count > size().
Returns a reference to the idx-th element of the sequence. The behavior is undefined if idx is out of range (i.e., if it is greater than or equal to size()).
|
inlineconstexprnoexcept |
Returns a reverse iterator to the first element of the reversed span. It corresponds to the last element of the non-reversed span. If the span is empty, the returned iterator is equal to rend().
|
inlineconstexprnoexcept |
Returns a reverse iterator to the element following the last element of the reversed span. It corresponds to the element preceding the first element of the non-reversed span. This element acts as a placeholder, attempting to access it results in undefined behavior.
Returns the number of elements in the span.
Returns the number of elements in the span.
|
inlineconstexpr |
Obtains a span that is a view over the Count elements of this span starting at offset Offset. If Count is etl::dynamic_extent, the number of elements in the subspan is size() - offset (i.e., it ends at the end of *this.).
|
inlineconstexpr |
Obtains a span that is a view over the Count elements of this span starting at offset Offset. If Count is etl::dynamic_extent, the number of elements in the subspan is size() - offset (i.e., it ends at the end of *this.).
The number of elements in the sequence, or etl::dynamic_extent if dynamic.