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

MutSpan is a non-owning reference to a continuous array of objects which can be mutated through the span. More...

#include <span.h>

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

Public Member Functions

T * begin ()
 Returns a pointer to the beginning of the region. More...
 
T const * begin () const
 Returns a pointer-to-const to the beginning of the region. More...
 
T * end ()
 Returns a pointer to one past the end of the region. More...
 
T const * end () const
 Returns a pointer-to-const to one past the end of the region. More...
 
 MutSpan ()=default
 Default ctor, initialises an empty region. More...
 
template<typename Container , std::enable_if_t< std::is_same_v< T, typename Container::value_type >, char > = 0>
 MutSpan (Container &c)
 Standard ctor. More...
 
 MutSpan (MutSpan< T > const &)=default
 Copy ctor. More...
 
 MutSpan (T *ptr_, std::size_t len)
 Alternative ctor, takes a pointer and a length. 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 & operator() (std::int64_t i)
 Returns a reference to the element at index i restricted to the range of region. 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 & operator[] (std::size_t i)
 Returns a reference to the element at index i. 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 * ptr {nullptr}
 Pointer 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::MutSpan< T >

MutSpan is a non-owning reference to a continuous array of objects which can be mutated through the span.

The region from which MutSpan has been initialised needs to live throughout the span's lifetime. It is not possible to extend or shrink the region, but each element in it can be modified through the span.

MutSpans can be created either using a 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 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: