SyTen
syten::SpanImpl::ConstSpan< T > Class Template Reference

ConstSpan is a non-owning constant reference to a continuous array of objects. More...

#include <span.h>

+ Collaboration diagram for syten::SpanImpl::ConstSpan< T >:

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 Ts. 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 Ts in the region. More...
 

Detailed Description

template<typename T>
class syten::SpanImpl::ConstSpan< T >

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.

ConstSpans can be created either using a constant reference to a container with a value_type member typedef or a plain pointer/size pair.

Remarks
Functionally, this is quite similar to a pair of constant random access iterators ‘begin’ and ‘end’.
Template Parameters
Tthe type of the objects in the region of memory.

The documentation for this class was generated from the following file: