LibSWOC++ 1.5.14
Solid Wall of C++
Loading...
Searching...
No Matches
swoc::MemSpan< void > Class Reference
Inheritance diagram for swoc::MemSpan< void >:
Inheritance graph
Collaboration diagram for swoc::MemSpan< void >:
Collaboration graph

Public Types

using value_type = void
 
using pointer_type = value_type *
 
using value_type
 Element type for span.
 
using iterator
 Iterator.
 
using const_iterator
 Constant iterator.
 
- Public Types inherited from swoc::MemSpan< T >
using value_type = T
 Element type for span.
 
using iterator = T *
 Iterator.
 
using const_iterator = T const *
 Constant iterator.
 

Public Member Functions

constexpr MemSpan ()=default
 Default constructor (empty buffer).
 
constexpr MemSpan (self_type const &that)=default
 Copy constructor.
 
constexpr self_typeoperator= (self_type const &that)=default
 Copy assignment.
 
template<typename U>
constexpr MemSpan (MemSpan< U > const &that)
 
constexpr MemSpan (value_type *start, size_t n)
 
 MemSpan (value_type *begin, value_type *end)
 
template<auto N, typename U>
constexpr MemSpan (U(&a)[N])
 
constexpr MemSpan (std::nullptr_t)
 
constexpr value_type * data () const
 Pointer to memory in the span.
 
value_type * data_end () const
 Pointer to just after memory in the span.
 
template<typename U>
self_typeoperator= (MemSpan< U > const &that)
 
template<typename C, typename = std::enable_if_t<!std::is_const_v<decltype(std::declval<C>().data()[0])> && std::is_convertible_v<decltype(std::declval<C>().size()), size_t>>
constexpr MemSpan (C const &c)
 
self_typeassign (value_type *ptr, size_t n)
 
self_typeassign (value_type *first, value_type const *last)
 
self_type prefix (size_t n) const
 
self_typeremove_prefix (size_t count)
 
self_type clip_prefix (size_t n)
 
self_type suffix (size_t n) const
 
self_typeremove_suffix (size_t n)
 
self_type clip_suffix (size_t n)
 
constexpr self_type subspan (size_t offset, size_t n) const
 
template<typename T>
self_type align () const
 
self_type align (size_t alignment) const
 
self_type align (size_t alignment, size_t obj_size) const
 
template<typename U>
MemSpan< U > rebind () const
 
template<typename U>
U * as_ptr () const
 
self_typeclear ()
 Clear the span (become an empty span).
 
auto make (Args &&...args) -> self_type &
 
constexpr MemSpan (MemSpan< U > const &that)
 
constexpr MemSpan (U(&a)[N])
 
template<typename U>
auto operator= (MemSpan< U > const &that) -> self_type &
 
template<typename T>
auto align () const -> self_type
 
auto rebind () const -> self_type
 
template<>
auto rebind () const -> self_type
 
template<>
auto rebind () const -> MemSpan< void const >
 
constexpr MemSpan ()=default
 Default constructor (empty buffer).
 
constexpr MemSpan (self_type const &that)=default
 Copy constructor.
 
constexpr MemSpan (self_type &that)=default
 Copy constructor.
 
constexpr MemSpan (value_type *ptr, size_t count)
 
constexpr MemSpan (value_type *begin, value_type *end)
 
constexpr MemSpan (void(&a)[N])
 
constexpr MemSpan (std::array< U, N > const &a)
 
constexpr MemSpan (std::array< void, N > &a)
 
constexpr MemSpan (MemSpan< U > const &that)
 
constexpr MemSpan (C &c)
 
constexpr MemSpan (C const &c)
 
constexpr MemSpan (std::nullptr_t)
 
constexpr MemSpan (MemSpan< U > const &that)
 
constexpr MemSpan (U(&a)[N])
 
constexpr bool operator== (self_type const &that) const
 
bool is_same (self_type const &that) const
 
constexpr bool operator!= (self_type const &that) const
 
self_typeoperator= (self_type const &that)=default
 Assignment - the span is copied, not the content.
 
void & operator[] (size_t idx) const
 Access element at index idx.
 
bool operator! () const
 
 operator bool () const
 
constexpr bool empty () const
 
auto rebind () const -> self_type
 
auto make (Args &&...args) -> self_type &
 
- Public Member Functions inherited from swoc::MemSpan< T >
constexpr MemSpan ()=default
 Default constructor (empty buffer).
 
constexpr MemSpan (self_type const &that)=default
 Copy constructor.
 
constexpr MemSpan (self_type &that)=default
 Copy constructor.
 
constexpr MemSpan (value_type *ptr, size_t count)
 
constexpr MemSpan (value_type *begin, value_type *end)
 
template<auto N>
constexpr MemSpan (T(&a)[N])
 
template<auto N, typename U, typename META = std::enable_if_t<std::conjunction_v<std::is_const<T>, std::is_same<std::remove_const_t<U>, std::remove_const_t<T>>>>>
constexpr MemSpan (std::array< U, N > const &a)
 
template<auto N>
constexpr MemSpan (std::array< T, N > &a)
 
template<typename U, typename META = std::enable_if_t<std::conjunction_v<std::is_const<T>, std::is_same<U, std::remove_const_t<T>>>>>
constexpr MemSpan (MemSpan< U > const &that)
 
template<typename C, typename = std::enable_if_t<std::is_convertible_v<decltype(std::declval<C>().data()), T *> && std::is_convertible_v<decltype(std::declval<C>().size()), size_t>>
constexpr MemSpan (C &c)
 
template<typename C, typename = std::enable_if_t<std::is_convertible_v<decltype(std::declval<C>().data()), T *> && std::is_convertible_v<decltype(std::declval<C>().size()), size_t>>
constexpr MemSpan (C const &c)
 
constexpr MemSpan (std::nullptr_t)
 
constexpr bool operator== (self_type const &that) const
 
bool is_same (self_type const &that) const
 
constexpr bool operator!= (self_type const &that) const
 
self_typeoperator= (self_type const &that)=default
 Assignment - the span is copied, not the content.
 
T & operator[] (size_t idx) const
 Access element at index idx.
 
bool operator! () const
 
 operator bool () const
 
constexpr bool empty () const
 
template<typename... Args>
auto make (Args &&...args) -> self_type &
 
template<typename U>
constexpr MemSpan (MemSpan< U > const &that)
 
template<auto N, typename U>
constexpr MemSpan (U(&a)[N])
 
auto rebind () const -> self_type
 
constexpr T * begin () const
 Pointer to the first element in the span.
 
constexpr T * end () const
 Pointer to first element not in the span.
 
constexpr size_t size () const
 Number of elements in the span.
 
constexpr size_t count () const
 
constexpr size_t length () const
 Number of elements in the span.
 
constexpr size_t data_size () const
 Number of bytes in the span.
 
T * data () const
 
constexpr T * data_end () const
 
T & front ()
 
T & back ()
 
template<typename F>
self_typeapply (F &&f)
 
template<typename U = std::conditional_t<std::is_const_v<T>, void const, void>>
MemSpan< U > rebind () const
 
self_typeassign (T *ptr, size_t count)
 
self_typeassign (T *first, T const *last)
 
self_typeclear ()
 Clear the span (become an empty span).
 
bool contains (value_type const *p) const
 
constexpr self_type prefix (size_t count) const
 
constexpr self_type first (size_t count) const
 
self_typeremove_prefix (size_t count)
 
self_type clip_prefix (size_t count)
 
constexpr self_type suffix (size_t count) const
 
constexpr self_type last (size_t count) const
 
self_typeremove_suffix (size_t count)
 
self_type clip_suffix (size_t count)
 
constexpr self_type subspan (size_t offset, size_t count) const
 
constexpr self_typerestrict (size_t n)
 
template<typename... Args>
self_typemake (Args &&...args)
 
void destroy ()
 Destruct all elements in the span.
 

Protected Member Functions

 MemSpan (super_type const &super)
 

Protected Attributes

void * _ptr
 Pointer to base of memory chunk.
 
size_t _count
 Number of elements.
 
- Protected Attributes inherited from swoc::MemSpan< T >
T * _ptr = nullptr
 Pointer to base of memory chunk.
 
size_t _count = 0
 Number of elements.
 

Accessors.

constexpr void * begin () const
 Pointer to the first element in the span.
 
constexpr void * end () const
 Pointer to first element not in the span.
 
constexpr size_t size () const
 Number of elements in the span.
 
constexpr size_t count () const
 
constexpr size_t length () const
 Number of elements in the span.
 
constexpr size_t data_size () const
 Number of bytes in the span.
 
void * data () const
 
constexpr void * data_end () const
 
void & front ()
 
void & back ()
 
self_typeapply (F &&f)
 
MemSpan< U > rebind () const
 
self_typeassign (void *ptr, size_t count)
 
self_typeassign (void *first, void const *last)
 
self_typeclear ()
 Clear the span (become an empty span).
 
bool contains (value_type const *p) const
 
constexpr self_type prefix (size_t count) const
 
constexpr self_type first (size_t count) const
 
self_typeremove_prefix (size_t count)
 
self_type clip_prefix (size_t count)
 
constexpr self_type suffix (size_t count) const
 
constexpr self_type last (size_t count) const
 
self_typeremove_suffix (size_t count)
 
self_type clip_suffix (size_t count)
 
constexpr self_type subspan (size_t offset, size_t count) const
 
constexpr self_typerestrict (size_t n)
 
self_typemake (Args &&...args)
 
void destroy ()
 Destruct all elements in the span.
 

Detailed Description

Definition at line 650 of file MemSpan.h.

Member Typedef Documentation

◆ const_iterator

using swoc::MemSpan< void >::const_iterator

Constant iterator.

Definition at line 60 of file MemSpan.h.

◆ iterator

using swoc::MemSpan< void >::iterator

Iterator.

Definition at line 59 of file MemSpan.h.

◆ pointer_type

using swoc::MemSpan< void >::pointer_type = value_type *

Definition at line 657 of file MemSpan.h.

◆ value_type [1/2]

using swoc::MemSpan< void >::value_type

Element type for span.

Definition at line 58 of file MemSpan.h.

◆ value_type [2/2]

using swoc::MemSpan< void >::value_type = void

Definition at line 656 of file MemSpan.h.

Constructor & Destructor Documentation

◆ MemSpan() [1/20]

template<typename U>
swoc::MemSpan< void >::MemSpan ( MemSpan< U > const & that)
constexpr

Cross type copy constructor.

Template Parameters
UType for source span.
Parameters
thatSource span. ` This enables any MemSpan to be automatically converted to a void span, just as any pointer can convert to a void pointer.

Definition at line 1335 of file MemSpan.h.

◆ MemSpan() [2/20]

swoc::MemSpan< void >::MemSpan ( value_type * start,
size_t n )
inlineconstexpr

Construct from a pointer start and a size n bytes.

Parameters
startStart of the span.
n# of bytes in the span.

Definition at line 1342 of file MemSpan.h.

◆ MemSpan() [3/20]

swoc::MemSpan< void >::MemSpan ( value_type * begin,
value_type * end )
inline

Construct from a half open range of [start, last).

Parameters
beginStart of the range.
endPast end of range.

Definition at line 1346 of file MemSpan.h.

◆ MemSpan() [4/20]

template<auto N, typename U>
swoc::MemSpan< void >::MemSpan ( U(&) a[N])
constexpr

Construct to cover an array.

Template Parameters
NNumber of elements in the array.
UElement type.
Parameters
aThe array.

Definition at line 1357 of file MemSpan.h.

◆ MemSpan() [5/20]

swoc::MemSpan< void >::MemSpan ( std::nullptr_t )
inlineconstexpr

Construct from nullptr. This implicitly makes the length 0.

Definition at line 1368 of file MemSpan.h.

◆ MemSpan() [6/20]

template<typename C, typename>
swoc::MemSpan< void >::MemSpan ( C const & c)
constexpr

Construct from any vector like container.

Template Parameters
CContainer type.
Parameters
ccontainer

The container type must have the methods data and size which must return values convertible to void* and size_t respectively.

Definition at line 1365 of file MemSpan.h.

◆ MemSpan() [7/20]

swoc::MemSpan< void >::MemSpan ( super_type const & super)
inlineprotected

Construct from const void span.

Parameters
superSource span.
Note
This is protected because it can only be used in situations were const correctness is not violated by converting a const span. The primary use is to enable void span method implementations to return a const span as self_type without explicit casting. In such cases the original span was not const and so there is no violation.

Definition at line 861 of file MemSpan.h.

◆ MemSpan() [8/20]

swoc::MemSpan< void >::MemSpan ( MemSpan< U > const & that)
constexpr

Definition at line 1333 of file MemSpan.h.

◆ MemSpan() [9/20]

swoc::MemSpan< void >::MemSpan ( U(&) a[N])
constexpr

Definition at line 1349 of file MemSpan.h.

◆ MemSpan() [10/20]

swoc::MemSpan< void >::MemSpan ( value_type * ptr,
size_t count )
inlineconstexpr

Construct from a first element start and a count of elements.

Parameters
startFirst element.
countTotal number of elements.

Definition at line 75 of file MemSpan.h.

◆ MemSpan() [11/20]

swoc::MemSpan< void >::MemSpan ( value_type * begin,
value_type * end )
inlineconstexpr

Construct from a half open range [start, last).

Parameters
beginStart of range.
endPast end of range.

Definition at line 82 of file MemSpan.h.

◆ MemSpan() [12/20]

swoc::MemSpan< void >::MemSpan ( void(&) a[N])
constexpr

Construct to cover an array.

Template Parameters
NNumber of elements in the array.
Parameters
aThe array.

Definition at line 89 of file MemSpan.h.

◆ MemSpan() [13/20]

swoc::MemSpan< void >::MemSpan ( std::array< U, N > const & a)
constexpr

Construct from constant std::array.

Template Parameters
NArray size.
Parameters
aArray instance.
Note
Because the elements in a constant array are constant the span value type must be constant.

Definition at line 101 of file MemSpan.h.

◆ MemSpan() [14/20]

swoc::MemSpan< void >::MemSpan ( std::array< void, N > & a)
constexpr

Construct from a std::array.

Template Parameters
NArray size.
Parameters
aArray instance.

Definition at line 108 of file MemSpan.h.

◆ MemSpan() [15/20]

swoc::MemSpan< void >::MemSpan ( MemSpan< U > const & that)
inlineconstexpr

Construct a span of constant values from a span of non-constant.

Template Parameters
USpan types.
METAMetaprogramming type to control conversion existence.
Parameters
thatSource span.

This enables the standard conversion from non-const to const.

Definition at line 120 of file MemSpan.h.

◆ MemSpan() [16/20]

swoc::MemSpan< void >::MemSpan ( C & c)
constexpr

Construct from any vector like container.

Template Parameters
CContainer type.
Parameters
ccontainer

The container type must have the methods data and size which must return values convertible to the pointer type for T and size_t respectively.

Definition at line 138 of file MemSpan.h.

◆ MemSpan() [17/20]

swoc::MemSpan< C, typename >::MemSpan ( C const & c)
constexpr

Construct from any vector like container.

Template Parameters
CContainer type.
Parameters
ccontainer

The container type must have the methods data and size which must return values convertible to the pointer type for T and size_t respectively.

Note
Because the container is passed as a constant reference, this may cause the span type to also be a constant element type.

Definition at line 154 of file MemSpan.h.

◆ MemSpan() [18/20]

swoc::MemSpan< void >::MemSpan ( std::nullptr_t )
inlineconstexpr

Construct from nullptr. This implicitly makes the length 0.

Definition at line 159 of file MemSpan.h.

◆ MemSpan() [19/20]

swoc::MemSpan< void >::MemSpan ( MemSpan< U > const & that)
constexpr

Definition at line 1333 of file MemSpan.h.

◆ MemSpan() [20/20]

swoc::MemSpan< void >::MemSpan ( U(&) a[N])
constexpr

Definition at line 1349 of file MemSpan.h.

Member Function Documentation

◆ align() [1/4]

template<typename T>
self_type swoc::MemSpan< void >::align ( ) const

Align span for a type.

Template Parameters
TAlignment type.
Returns
A suffix of the span suitably aligned for T.

The minimum amount of space is removed from the front to yield an aligned span. If the span is not large enough to perform the alignment, the pointer is aligned and the size reduced to zero (empty).

◆ align() [2/4]

template<typename T>
auto swoc::MemSpan< void >::align ( ) const -> self_type

Definition at line 1611 of file MemSpan.h.

◆ align() [3/4]

auto swoc::MemSpan< void >::align ( size_t alignment) const
inline

Force memory alignment.

Parameters
alignmentAlignment size (must be power of 2).
Returns
An aligned span.

The minimum amount of space is removed from the front to yield an aligned span. If the span is not large enough to perform the alignment, the pointer is aligned and the size reduced to zero (empty).

Definition at line 1627 of file MemSpan.h.

◆ align() [4/4]

auto swoc::MemSpan< void >::align ( size_t alignment,
size_t obj_size ) const
inline

Force memory alignment.

Parameters
alignmentAlignment size (must be power of 2).
obj_sizeSize of instances requiring alignment.
Returns
An aligned span.

The minimum amount of space is removed from the front to yield an aligned span. If the span is not large enough to perform the alignment, the pointer is aligned and the size reduced to zero (empty). Trailing space is discarded such that the resulting memory space is a multiple of size.

Note
obj_size should be a multiple of alignment. This happens naturally if sizeof is used.

Definition at line 1644 of file MemSpan.h.

◆ apply()

MemSpan< void >::self_type & swoc::MemSpan< void >::apply ( F && f)

Apply a function f to every element of the span.

Template Parameters
FFunctor type.
Parameters
fFunctor instance.
Returns
this

Definition at line 246 of file MemSpan.h.

◆ as_ptr()

template<typename U>
U * swoc::MemSpan< void >::as_ptr ( ) const

Cast the span as a the instance of a type.

Template Parameters
UTarget type.
Returns
A pointer to the span as a constant instance of U.
Note
This throws if the size is not a match for U.

Definition at line 1683 of file MemSpan.h.

◆ assign() [1/4]

auto swoc::MemSpan< void >::assign ( value_type * first,
value_type const * last )
inline

Update the span.

Parameters
firstFirst element in the span.
lastOne past the last element in the span.
Returns
this

Definition at line 1443 of file MemSpan.h.

◆ assign() [2/4]

auto swoc::MemSpan< void >::assign ( value_type * ptr,
size_t n )
inline

Update the span.

Parameters
ptrStart of span memory.
nNumber of elements in the span.
Returns
this

Definition at line 1430 of file MemSpan.h.

◆ assign() [3/4]

auto swoc::MemSpan< void >::assign ( void * first,
void const * last )
inline

Adjust the span.

Parameters
firstStarting point of the span.
lastPast the end of the span.
Returns
this

Definition at line 272 of file MemSpan.h.

◆ assign() [4/4]

auto swoc::MemSpan< void >::assign ( void * ptr,
size_t count )
inline

Set the span. This is faster but equivalent to constructing a new span with the same arguments and assigning it.

Returns
this.
Parameters
ptrBuffer start.
count

of elements.

Definition at line 262 of file MemSpan.h.

◆ back()

void & swoc::MemSpan< void >::back ( )

Access the last element in the span.

Returns
A reference to the last element in the span.

Definition at line 238 of file MemSpan.h.

◆ begin()

void * swoc::MemSpan< void >::begin ( ) const
constexpr

Pointer to the first element in the span.

Definition at line 204 of file MemSpan.h.

◆ clear() [1/2]

auto swoc::MemSpan< void >::clear ( )
inline

Clear the span (become an empty span).

Definition at line 275 of file MemSpan.h.

◆ clear() [2/2]

auto swoc::MemSpan< void >::clear ( )
inline

Clear the span (become an empty span).

Definition at line 1456 of file MemSpan.h.

◆ clip_prefix() [1/2]

auto swoc::MemSpan< void >::clip_prefix ( size_t count)
inline

Remove and return a prefix.

Parameters
countNumber of items in the prefix.
Returns
The removed prefix.

count items are removed from the beginning of this and a view of those elements is returned.

Definition at line 308 of file MemSpan.h.

◆ clip_prefix() [2/2]

auto swoc::MemSpan< void >::clip_prefix ( size_t n)
inline

Remove and return a prefix.

Parameters
countNumber of byte in the prefix.
Returns
The removed prefix.

n bytes are removed from the beginning of this and a view of those bytes is returned.

Definition at line 1568 of file MemSpan.h.

◆ clip_suffix() [1/2]

auto swoc::MemSpan< void >::clip_suffix ( size_t count)
inline

Remove and return a suffix.

Parameters
countNumber of items in the suffix.
Returns
The removed suffix.

count items are removed from the end of this and a view of those elements is returned.

Definition at line 340 of file MemSpan.h.

◆ clip_suffix() [2/2]

auto swoc::MemSpan< void >::clip_suffix ( size_t n)
inline

Remove and return a suffix.

Parameters
nNumber of items in the suffix.
Returns
The removed suffix.

n bytes are removed from the end of this and a view of those bytes is returned.

Definition at line 1584 of file MemSpan.h.

◆ contains()

bool swoc::MemSpan< void >::contains ( value_type const * p) const
inline
Returns
true if the byte at *p is in the span.

Definition at line 278 of file MemSpan.h.

◆ count()

size_t swoc::MemSpan< void >::count ( ) const
inlineconstexpr

Number of elements in the span

Note
Deprecate for 1.5.0.

Definition at line 214 of file MemSpan.h.

◆ data() [1/2]

void const * swoc::MemSpan< void >::data ( ) const
inlineconstexpr
Returns
Pointer to memory in the span.

Definition at line 223 of file MemSpan.h.

◆ data() [2/2]

void * swoc::MemSpan< void >::data ( ) const
inlineconstexpr

Pointer to memory in the span.

Definition at line 1467 of file MemSpan.h.

◆ data_end() [1/2]

void const * swoc::MemSpan< void >::data_end ( ) const
inlineconstexpr
Returns
Pointer to immediate after memory in the span.

Definition at line 226 of file MemSpan.h.

◆ data_end() [2/2]

void * swoc::MemSpan< void >::data_end ( ) const
inline

Pointer to just after memory in the span.

Definition at line 1477 of file MemSpan.h.

◆ data_size()

size_t swoc::MemSpan< void >::data_size ( ) const
inlineconstexpr

Number of bytes in the span.

Definition at line 220 of file MemSpan.h.

◆ destroy()

void swoc::MemSpan< void >::destroy ( )

Destruct all elements in the span.

Definition at line 370 of file MemSpan.h.

◆ empty()

bool swoc::MemSpan< void >::empty ( ) const
inlineconstexpr

Check for empty span (no content).

See also
operator bool

Definition at line 199 of file MemSpan.h.

◆ end()

void * swoc::MemSpan< void >::end ( ) const
constexpr

Pointer to first element not in the span.

Definition at line 207 of file MemSpan.h.

◆ first()

auto swoc::MemSpan< void >::first ( size_t count) const
constexpr

Get the initial segment of count elements.

Returns
An instance that contains the leading count elements of this.
Note
Synonymn for prefix for STL compatibility.

Definition at line 292 of file MemSpan.h.

◆ front()

void & swoc::MemSpan< void >::front ( )

Access the first element in the span.

Returns
A reference to the first element in the span.

Definition at line 232 of file MemSpan.h.

◆ is_same()

bool swoc::MemSpan< void >::is_same ( self_type const & that) const
inline

Identical.

Check if the spans refer to the same span of memory.

Returns
true if this and that refer to the same span, false if not.

Definition at line 175 of file MemSpan.h.

◆ last()

MemSpan< void > swoc::MemSpan< void >::last ( size_t count) const
constexpr

Get the trailing segment of count elements.

Parameters
countNumber of elements to retrieve.
Returns
An instance that contains the trailing count elements of this.
Note
Synonymn for suffix for STL compatibility.

Definition at line 324 of file MemSpan.h.

◆ length()

size_t swoc::MemSpan< void >::length ( ) const
inlineconstexpr

Number of elements in the span.

Definition at line 217 of file MemSpan.h.

◆ make() [1/3]

self_type & swoc::MemSpan< void >::make ( Args &&... args)

Construct all elements in the span.

For each element in the span, construct an instance of the span type using the args. If the instances need destruction this must be done explicitly.

◆ make() [2/3]

auto swoc::MemSpan< void >::make ( Args &&... args) -> self_type &

Definition at line 1315 of file MemSpan.h.

◆ make() [3/3]

auto swoc::MemSpan< void >::make ( Args &&... args) -> self_type &

Definition at line 1315 of file MemSpan.h.

◆ operator bool()

swoc::MemSpan< void >::operator bool ( ) const
inlineexplicit

Check for non-empty span.

Returns
true if the span contains bytes.

Definition at line 195 of file MemSpan.h.

◆ operator!()

bool swoc::MemSpan< void >::operator! ( ) const
inline

Check for empty span.

Returns
true if the span is empty (no contents), false otherwise.

Definition at line 191 of file MemSpan.h.

◆ operator!=()

bool swoc::MemSpan< void >::operator!= ( self_type const & that) const
inlineconstexpr

Inequality.

Returns
true if that does not refer to the same span as this, false otherwise.

Definition at line 181 of file MemSpan.h.

◆ operator=() [1/3]

template<typename U>
self_type & swoc::MemSpan< void >::operator= ( MemSpan< U > const & that)

Assignment - the span is copied, not the content. Any type of MemSpan can be assigned to MemSpan<void>.

◆ operator=() [2/3]

template<typename U>
auto swoc::MemSpan< void >::operator= ( MemSpan< U > const & that) -> self_type &

Definition at line 1416 of file MemSpan.h.

◆ operator=() [3/3]

auto swoc::MemSpan< void >::operator= ( self_type const & that)
inlineconstexprdefault

Assignment - the span is copied, not the content.

Definition at line 184 of file MemSpan.h.

◆ operator==()

bool swoc::MemSpan< void >::operator== ( self_type const & that) const
inlineconstexpr

Equality.

Compare the span contents.

Returns
true if the contents of that are the same as the content of this, false otherwise.

Definition at line 168 of file MemSpan.h.

◆ operator[]()

void & swoc::MemSpan< void >::operator[] ( size_t idx) const

Access element at index idx.

Definition at line 187 of file MemSpan.h.

◆ prefix() [1/2]

auto swoc::MemSpan< void >::prefix ( size_t count) const
inlineconstexpr

Get the initial segment of count elements.

Returns
An instance that contains the leading count elements of this.

Definition at line 284 of file MemSpan.h.

◆ prefix() [2/2]

auto swoc::MemSpan< void >::prefix ( size_t n) const
inline
Returns
An instance that contains the leading n bytes of this.

Definition at line 1512 of file MemSpan.h.

◆ rebind() [1/6]

MemSpan< U > swoc::MemSpan< U >::rebind ( ) const

Make a copy of this span on the same memory but of type U.

Template Parameters
UType for the created span.
Returns
A MemSpan which contains the same memory as instances of U.

if no type is specified, the default is void or void const according to whether value_type is const.

Definition at line 256 of file MemSpan.h.

◆ rebind() [2/6]

template<typename U>
MemSpan< U > swoc::MemSpan< void >::rebind ( ) const

Create a new span for a different type V on the same memory.

Template Parameters
VType for the created span.
Returns
A MemSpan which contains the same memory as instances of V.

Definition at line 1658 of file MemSpan.h.

◆ rebind() [3/6]

template<>
auto swoc::MemSpan< void >::rebind ( ) const -> MemSpan<void const>
inline

Definition at line 1677 of file MemSpan.h.

◆ rebind() [4/6]

auto swoc::MemSpan< voidconst >::rebind ( ) const -> self_type
inline

Definition at line 1665 of file MemSpan.h.

◆ rebind() [5/6]

auto swoc::MemSpan< voidconst >::rebind ( ) const -> self_type
inline

Definition at line 1665 of file MemSpan.h.

◆ rebind() [6/6]

template<>
auto swoc::MemSpan< void >::rebind ( ) const -> self_type
inline

Definition at line 1671 of file MemSpan.h.

◆ remove_prefix() [1/2]

auto swoc::MemSpan< void >::remove_prefix ( size_t count)
inline

Shrink the span by removing count leading elements.

Parameters
countThe number of elements to remove.
Returns
*this

Definition at line 299 of file MemSpan.h.

◆ remove_prefix() [2/2]

auto swoc::MemSpan< void >::remove_prefix ( size_t count)
inline

Shrink the span by removing n leading bytes.

Parameters
countThe number of elements to remove.
Returns
*this

Definition at line 1525 of file MemSpan.h.

◆ remove_suffix() [1/2]

auto swoc::MemSpan< void >::remove_suffix ( size_t count)
inline

Shrink the span by removing count trailing elements.

Parameters
countNumber of elements to remove.
Returns
*this

Definition at line 331 of file MemSpan.h.

◆ remove_suffix() [2/2]

auto swoc::MemSpan< void >::remove_suffix ( size_t n)
inline

Shrink the span by removing n bytes.

Parameters
nNumber of bytes to remove.
Returns
*this

Definition at line 1549 of file MemSpan.h.

◆ restrict()

auto swoc::MemSpan< void >::restrict ( size_t n)
constexpr

Limit the size of the span.

Parameters
nMaximum number of elements.
Returns
this

If the number of elements is greater than n, the size is changed to n.

Definition at line 360 of file MemSpan.h.

◆ size()

size_t swoc::MemSpan< void >::size ( ) const
inlineconstexpr

Number of elements in the span.

Definition at line 210 of file MemSpan.h.

◆ subspan() [1/2]

auto swoc::MemSpan< void >::subspan ( size_t offset,
size_t count ) const
inlineconstexpr

Return a sub span of this span.

Parameters
offsetOffset (index) of first element in subspan.
countNumber of elements in the subspan.
Returns
A subspan starting at offset for count elements.

The result is clipped by this - if offset is out of range an empty span is returned. Otherwise count is clipped by the number of elements available in this.

Definition at line 351 of file MemSpan.h.

◆ subspan() [2/2]

auto swoc::MemSpan< void >::subspan ( size_t offset,
size_t n ) const
inlineconstexpr

Return a sub span of this span.

Parameters
offsetOffset (index) of first element.
nNumber of elements.
Returns
The span starting at offset for count elements in this.

The result is clipped by this - if offset is out of range an empty span is returned. Otherwise count is clipped by the number of elements available in this. In effect the intersection of the span described by ( offset , count ) and this span is returned, which may be the empty span.

Definition at line 1594 of file MemSpan.h.

◆ suffix() [1/2]

auto swoc::MemSpan< void >::suffix ( size_t count) const
inlineconstexpr

Get the trailing segment of count elements.

Parameters
countNumber of elements to retrieve.
Returns
An instance that contains the trailing count elements of this.

Definition at line 315 of file MemSpan.h.

◆ suffix() [2/2]

auto swoc::MemSpan< void >::suffix ( size_t n) const
inline

Get the trailing segment of n bytes.

Parameters
nNumber of bytes to retrieve.
Returns
An instance that contains the trailing count elements of this.

Definition at line 1537 of file MemSpan.h.

Friends And Related Symbol Documentation

◆ MemSpan [1/2]

friend class MemSpan
friend

Definition at line 372 of file MemSpan.h.

◆ MemSpan [2/2]

template<typename U>
friend class MemSpan
friend

Definition at line 653 of file MemSpan.h.

Member Data Documentation

◆ _count

size_t swoc::MemSpan< void >::_count
protected

Number of elements.

Definition at line 55 of file MemSpan.h.

◆ _ptr

void* swoc::MemSpan< void >::_ptr
protected

Pointer to base of memory chunk.

Definition at line 54 of file MemSpan.h.


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