Template Class spanrs

Inheritance Relationships

Base Type

Class Documentation

template<class T, class I = C4_SIZE_TYPE>
class spanrs : public c4::span_crtp<T, C4_SIZE_TYPE, spanrs<T, C4_SIZE_TYPE>>

A non-owning span resizeable up to a capacity. Subselection or resizing will keep the original provided it starts at begin(). If subselection or resizing change the pointer, then the original capacity information will be lost.

Thus, resizing via resize() and ltrim() and subselecting via first() or any of subspan() or range() when starting from the beginning will keep the original capacity. OTOH, using last(), or any of subspan() or range() with an offset from the start will remove from capacity (shifting the pointer) by the corresponding offset. If this is undesired, then consider using spanrsl.

See also

spanrs for a span resizeable on the right

See also

spanrsl for a span resizeable on the right and left

Construction and assignment from same type

inline C4_ALWAYS_INLINE spanrs(T *p, I sz) noexcept
inline C4_ALWAYS_INLINE void assign (T *p, I sz) noexcept

Warning

will reset the capacity to sz

inline C4_ALWAYS_INLINE spanrs(T *p, I sz, I cap) noexcept
inline C4_ALWAYS_INLINE void assign (T *p, I sz, I cap) noexcept
template<size_t N>
inline C4_ALWAYS_INLINE spanrs(T (&arr)[N]) noexcept
template<size_t N> inline C4_ALWAYS_INLINE void assign (T(&arr)[N]) noexcept
inline C4_ALWAYS_INLINE spanrs(c4::aggregate_t, std::initializer_list<T> il) noexcept
inline C4_ALWAYS_INLINE void assign (c4::aggregate_t, std::initializer_list< T > il) noexcept

Public Types

using NCT = typename std::remove_const<T>::type

NCT=non const type.

using CT = typename std::add_const<T>::type

CT=const type.

using const_type = spanrs<CT, I>

Public Functions

_c4_DEFINE_ARRAY_TYPES(T, I)
inline C4_ALWAYS_INLINE operator span<T, I>() const noexcept

convert automatically to span of T

inline C4_ALWAYS_INLINE operator spanrs<CT, I>() const noexcept

convert automatically to span of const T

convert automatically to spanrs of const T

inline C4_ALWAYS_INLINE spanrs() noexcept
spanrs(spanrs const&) = default
spanrs(spanrs&&) = default
spanrs &operator=(spanrs const&) = default
spanrs &operator=(spanrs&&) = default
inline C4_ALWAYS_INLINE I capacity () const noexcept
inline C4_ALWAYS_INLINE void resize (I sz) C4_NOEXCEPT_A
inline C4_ALWAYS_INLINE void rtrim (I n) C4_NOEXCEPT_A
inline C4_ALWAYS_INLINE void ltrim (I n) C4_NOEXCEPT_A