ConstSpan is a non-owning constant reference to a continuous array of objects. More...
#include <span.h>
Public Member Functions | |
T const * | begin () const |
Returns a pointer-to-const to the beginning of the region. More... | |
ConstSpan ()=default | |
Default ctor, initialises an empty region. More... | |
ConstSpan (ConstSpan< T > const &)=default | |
Copy ctor. More... | |
template<typename Container , std::enable_if_t< std::is_same_v< T, typename Container::value_type >, char > = 0> | |
ConstSpan (Container const &c) | |
Standard ctor. More... | |
ConstSpan (MutSpan< T > c) | |
Alternative ctor from an existing MutSpan which provides a constant view on the same range as the MutSpan. More... | |
ConstSpan (std::initializer_list< T > l) | |
Alternative ctor from an initializer list of T s. More... | |
ConstSpan (T const *ptr_, std::size_t len) | |
Alternative ctor, takes a pointer and a length. More... | |
T const * | end () const |
Returns a pointer-to-const to one past the end of the region. More... | |
template<typename Container , std::enable_if_t< std::is_same_v< typename Container::value_type, T >, int > = 0> | |
operator Container () const | |
Conversion operator to the specified container. More... | |
template<std::size_t arr_sz> | |
operator std::array< T, arr_sz > () const | |
Conversion operator to the specified array. More... | |
T const & | operator() (std::int64_t i) const |
Returns a constant reference to the element at index i restricted to the range of region. More... | |
T const & | operator[] (std::size_t i) const |
Returns a constant reference to the element at index i . More... | |
std::size_t | size () const |
Returns the size of the region. More... | |
Private Attributes | |
T const * | ptr {nullptr} |
Pointer-to-const to the start of the region. More... | |
std::size_t | sz {0} |
Number of T s in the region. More... | |
ConstSpan is a non-owning constant reference to a continuous array of objects.
The region from which ConstSpan has been initialised needs to live throughout the span's lifetime. It is not possible to extend or shrink the region, nor is it possible to mutate the elements in the region.
ConstSpan
s can be created either using a constant reference to a container with a value_type
member typedef or a plain pointer/size pair.
T | the type of the objects in the region of memory. |