Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sysio::vm::span< T, Extent > Class Template Reference

#include <span.hpp>

Inheritance diagram for sysio::vm::span< T, Extent >:

Public Types

using element_type = T
 
using value_type = std::remove_cv_t<T>
 
using size_type = std::size_t
 
using difference_type = std::ptrdiff_t
 
using pointer = T*
 
using const_pointer = const T*
 
using reference = T&
 
using const_reference = const T&
 
using iterator = T*
 
using reverse_iterator = std::reverse_iterator<iterator>
 

Public Member Functions

template<std::size_t E = Extent, typename Enable = std::enable_if_t<E == dynamic_extent || E == 0>>
constexpr span () noexcept
 
constexpr span (pointer first, std::size_t len)
 
constexpr span (pointer first, pointer last)
 
template<std::size_t N, typename Enable = std::enable_if_t<(Extent == dynamic_extent || N == Extent)>>
constexpr span (T(&arr)[N]) noexcept
 
template<typename U , std::size_t N, typename Enable = std::enable_if_t<(Extent == dynamic_extent || N == Extent) && std::is_convertible_v<U(*)[], T(*)[]>>>
constexpr span (std::array< U, N > &arr) noexcept
 
template<typename U , std::size_t N, typename Enable = std::enable_if_t<(Extent == dynamic_extent || N == Extent) && std::is_convertible_v<const U(*)[], T(*)[]>>>
constexpr span (const std::array< U, N > &arr) noexcept
 
constexpr span (const span &)=default
 
constexpr span (span &&)=default
 
constexpr spanoperator= (const span &)=default
 
constexpr spanoperator= (span &&)=default
 
constexpr iterator begin () const noexcept
 
constexpr iterator end () const noexcept
 
constexpr reverse_iterator rbegin () const noexcept
 
constexpr reverse_iterator rend () const noexcept
 
constexpr Tfront () const
 
constexpr Tback () const
 
constexpr Toperator[] (std::size_t n) const
 
constexpr Tdata () const noexcept
 
constexpr std::size_t size () const noexcept
 
constexpr std::size_t size_bytes () const noexcept
 
constexpr bool empty () const noexcept
 
constexpr span< T, dynamic_extent > first (std::size_t len) const
 
constexpr span< T, dynamic_extent > last (std::size_t len) const
 
constexpr span< T, dynamic_extent > subspan (std::size_t offset, std::size_t len=dynamic_extent) const
 
template<std::size_t E = Extent, typename Enable = std::enable_if_t<E == dynamic_extent || E == 0>>
constexpr span () noexcept
 
constexpr span (pointer first, std::size_t len)
 
constexpr span (pointer first, pointer last)
 
template<std::size_t N, typename Enable = std::enable_if_t<(Extent == dynamic_extent || N == Extent)>>
constexpr span (T(&arr)[N]) noexcept
 
template<typename U , std::size_t N, typename Enable = std::enable_if_t<(Extent == dynamic_extent || N == Extent) && std::is_convertible_v<U(*)[], T(*)[]>>>
constexpr span (std::array< U, N > &arr) noexcept
 
template<typename U , std::size_t N, typename Enable = std::enable_if_t<(Extent == dynamic_extent || N == Extent) && std::is_convertible_v<const U(*)[], T(*)[]>>>
constexpr span (const std::array< U, N > &arr) noexcept
 
constexpr span (const span &)=default
 
constexpr span (span &&)=default
 
constexpr spanoperator= (const span &)=default
 
constexpr spanoperator= (span &&)=default
 
constexpr iterator begin () const noexcept
 
constexpr iterator end () const noexcept
 
constexpr reverse_iterator rbegin () const noexcept
 
constexpr reverse_iterator rend () const noexcept
 
constexpr Tfront () const
 
constexpr Tback () const
 
constexpr Toperator[] (std::size_t n) const
 
constexpr Tdata () const noexcept
 
constexpr std::size_t size () const noexcept
 
constexpr std::size_t size_bytes () const noexcept
 
constexpr bool empty () const noexcept
 
constexpr span< T, dynamic_extent > first (std::size_t len) const
 
constexpr span< T, dynamic_extent > last (std::size_t len) const
 
constexpr span< T, dynamic_extent > subspan (std::size_t offset, std::size_t len=dynamic_extent) const
 

Static Public Attributes

static constexpr std::size_t extent = Extent
 

Detailed Description

template<typename T, std::size_t Extent = dynamic_extent>
class sysio::vm::span< T, Extent >

Definition at line 14 of file span.hpp.

Member Typedef Documentation

◆ const_pointer

template<typename T , std::size_t Extent = dynamic_extent>
typedef const T * sysio::vm::span< T, Extent >::const_pointer = const T*

Definition at line 23 of file span.hpp.

◆ const_reference

template<typename T , std::size_t Extent = dynamic_extent>
typedef const T & sysio::vm::span< T, Extent >::const_reference = const T&

Definition at line 25 of file span.hpp.

◆ difference_type

template<typename T , std::size_t Extent = dynamic_extent>
typedef std::ptrdiff_t sysio::vm::span< T, Extent >::difference_type = std::ptrdiff_t

Definition at line 21 of file span.hpp.

◆ element_type

template<typename T , std::size_t Extent = dynamic_extent>
typedef T sysio::vm::span< T, Extent >::element_type = T

Definition at line 18 of file span.hpp.

◆ iterator

template<typename T , std::size_t Extent = dynamic_extent>
typedef T * sysio::vm::span< T, Extent >::iterator = T*

Definition at line 26 of file span.hpp.

◆ pointer

template<typename T , std::size_t Extent = dynamic_extent>
typedef T * sysio::vm::span< T, Extent >::pointer = T*

Definition at line 22 of file span.hpp.

◆ reference

template<typename T , std::size_t Extent = dynamic_extent>
typedef T & sysio::vm::span< T, Extent >::reference = T&

Definition at line 24 of file span.hpp.

◆ reverse_iterator

template<typename T , std::size_t Extent = dynamic_extent>
typedef std::reverse_iterator< iterator > sysio::vm::span< T, Extent >::reverse_iterator = std::reverse_iterator<iterator>

Definition at line 27 of file span.hpp.

◆ size_type

template<typename T , std::size_t Extent = dynamic_extent>
typedef std::size_t sysio::vm::span< T, Extent >::size_type = std::size_t

Definition at line 20 of file span.hpp.

◆ value_type

template<typename T , std::size_t Extent = dynamic_extent>
typedef std::remove_cv_t< T > sysio::vm::span< T, Extent >::value_type = std::remove_cv_t<T>

Definition at line 19 of file span.hpp.

Constructor & Destructor Documentation

◆ span() [1/16]

template<typename T , std::size_t Extent = dynamic_extent>
template<std::size_t E = Extent, typename Enable = std::enable_if_t<E == dynamic_extent || E == 0>>
sysio::vm::span< T, Extent >::span ( )
inlineconstexprnoexcept

Definition at line 31 of file span.hpp.

31: first_elem(nullptr), last_elem(nullptr) {}

◆ span() [2/16]

template<typename T , std::size_t Extent = dynamic_extent>
sysio::vm::span< T, Extent >::span ( pointer first,
std::size_t len )
inlineconstexpr

Definition at line 35 of file span.hpp.

35 : first_elem(first), last_elem(first + len) {
36 SYS_VM_ASSERT(Extent == dynamic_extent || Extent == size(), span_exception, "Wrong size for span with static extent");
37 }
constexpr std::size_t size() const noexcept
Definition span.hpp:73
constexpr span< T, dynamic_extent > first(std::size_t len) const
Definition span.hpp:77
#define SYS_VM_ASSERT(expr, exc_type, msg)
Definition exceptions.hpp:8
size_t len
Here is the call graph for this function:

◆ span() [3/16]

template<typename T , std::size_t Extent = dynamic_extent>
sysio::vm::span< T, Extent >::span ( pointer first,
pointer last )
inlineconstexpr

Definition at line 38 of file span.hpp.

38 : first_elem(first), last_elem(last) {
39 SYS_VM_ASSERT(last >= first, span_exception, "last iterator < first iterator");
40 SYS_VM_ASSERT(Extent == dynamic_extent || Extent == size(), span_exception, "Wrong size for span with static extent");
41 }
constexpr span< T, dynamic_extent > last(std::size_t len) const
Definition span.hpp:82
Here is the call graph for this function:

◆ span() [4/16]

template<typename T , std::size_t Extent = dynamic_extent>
template<std::size_t N, typename Enable = std::enable_if_t<(Extent == dynamic_extent || N == Extent)>>
sysio::vm::span< T, Extent >::span ( T(&) arr[N])
inlineconstexprnoexcept

Definition at line 44 of file span.hpp.

44: first_elem(&arr[0]), last_elem(&arr[0] + N) {}
const int N
Definition quantize.cpp:54

◆ span() [5/16]

template<typename T , std::size_t Extent = dynamic_extent>
template<typename U , std::size_t N, typename Enable = std::enable_if_t<(Extent == dynamic_extent || N == Extent) && std::is_convertible_v<U(*)[], T(*)[]>>>
sysio::vm::span< T, Extent >::span ( std::array< U, N > & arr)
inlineconstexprnoexcept

Definition at line 48 of file span.hpp.

48: first_elem(arr.data()), last_elem(arr.data() + N) {}

◆ span() [6/16]

template<typename T , std::size_t Extent = dynamic_extent>
template<typename U , std::size_t N, typename Enable = std::enable_if_t<(Extent == dynamic_extent || N == Extent) && std::is_convertible_v<const U(*)[], T(*)[]>>>
sysio::vm::span< T, Extent >::span ( const std::array< U, N > & arr)
inlineconstexprnoexcept

Definition at line 52 of file span.hpp.

52: first_elem(arr.data()), last_elem(arr.data() + N) {}

◆ span() [7/16]

template<typename T , std::size_t Extent = dynamic_extent>
sysio::vm::span< T, Extent >::span ( const span< T, Extent > & )
inlineconstexprdefault

◆ span() [8/16]

template<typename T , std::size_t Extent = dynamic_extent>
sysio::vm::span< T, Extent >::span ( span< T, Extent > && )
inlineconstexprdefault

◆ span() [9/16]

template<typename T , std::size_t Extent = dynamic_extent>
template<std::size_t E = Extent, typename Enable = std::enable_if_t<E == dynamic_extent || E == 0>>
sysio::vm::span< T, Extent >::span ( )
inlineconstexprnoexcept

Definition at line 31 of file span.hpp.

31: first_elem(nullptr), last_elem(nullptr) {}

◆ span() [10/16]

template<typename T , std::size_t Extent = dynamic_extent>
sysio::vm::span< T, Extent >::span ( pointer first,
std::size_t len )
inlineconstexpr

Definition at line 35 of file span.hpp.

35 : first_elem(first), last_elem(first + len) {
36 SYS_VM_ASSERT(Extent == dynamic_extent || Extent == size(), span_exception, "Wrong size for span with static extent");
37 }
Here is the call graph for this function:

◆ span() [11/16]

template<typename T , std::size_t Extent = dynamic_extent>
sysio::vm::span< T, Extent >::span ( pointer first,
pointer last )
inlineconstexpr

Definition at line 38 of file span.hpp.

38 : first_elem(first), last_elem(last) {
39 SYS_VM_ASSERT(last >= first, span_exception, "last iterator < first iterator");
40 SYS_VM_ASSERT(Extent == dynamic_extent || Extent == size(), span_exception, "Wrong size for span with static extent");
41 }
Here is the call graph for this function:

◆ span() [12/16]

template<typename T , std::size_t Extent = dynamic_extent>
template<std::size_t N, typename Enable = std::enable_if_t<(Extent == dynamic_extent || N == Extent)>>
sysio::vm::span< T, Extent >::span ( T(&) arr[N])
inlineconstexprnoexcept

Definition at line 44 of file span.hpp.

44: first_elem(&arr[0]), last_elem(&arr[0] + N) {}

◆ span() [13/16]

template<typename T , std::size_t Extent = dynamic_extent>
template<typename U , std::size_t N, typename Enable = std::enable_if_t<(Extent == dynamic_extent || N == Extent) && std::is_convertible_v<U(*)[], T(*)[]>>>
sysio::vm::span< T, Extent >::span ( std::array< U, N > & arr)
inlineconstexprnoexcept

Definition at line 48 of file span.hpp.

48: first_elem(arr.data()), last_elem(arr.data() + N) {}

◆ span() [14/16]

template<typename T , std::size_t Extent = dynamic_extent>
template<typename U , std::size_t N, typename Enable = std::enable_if_t<(Extent == dynamic_extent || N == Extent) && std::is_convertible_v<const U(*)[], T(*)[]>>>
sysio::vm::span< T, Extent >::span ( const std::array< U, N > & arr)
inlineconstexprnoexcept

Definition at line 52 of file span.hpp.

52: first_elem(arr.data()), last_elem(arr.data() + N) {}

◆ span() [15/16]

template<typename T , std::size_t Extent = dynamic_extent>
sysio::vm::span< T, Extent >::span ( const span< T, Extent > & )
inlineconstexprdefault

◆ span() [16/16]

template<typename T , std::size_t Extent = dynamic_extent>
sysio::vm::span< T, Extent >::span ( span< T, Extent > && )
inlineconstexprdefault

Member Function Documentation

◆ back() [1/2]

template<typename T , std::size_t Extent = dynamic_extent>
T & sysio::vm::span< T, Extent >::back ( ) const
inlineconstexpr

Definition at line 69 of file span.hpp.

69{ return *(last_elem - 1); }

◆ back() [2/2]

template<typename T , std::size_t Extent = dynamic_extent>
T & sysio::vm::span< T, Extent >::back ( ) const
inlineconstexpr

Definition at line 69 of file span.hpp.

69{ return *(last_elem - 1); }

◆ begin() [1/2]

template<typename T , std::size_t Extent = dynamic_extent>
iterator sysio::vm::span< T, Extent >::begin ( ) const
inlineconstexprnoexcept

Definition at line 63 of file span.hpp.

63{ return first_elem; }

◆ begin() [2/2]

template<typename T , std::size_t Extent = dynamic_extent>
iterator sysio::vm::span< T, Extent >::begin ( ) const
inlineconstexprnoexcept

Definition at line 63 of file span.hpp.

63{ return first_elem; }

◆ data() [1/2]

template<typename T , std::size_t Extent = dynamic_extent>
T * sysio::vm::span< T, Extent >::data ( ) const
inlineconstexprnoexcept

Definition at line 72 of file span.hpp.

72{ return first_elem; }
Here is the caller graph for this function:

◆ data() [2/2]

template<typename T , std::size_t Extent = dynamic_extent>
T * sysio::vm::span< T, Extent >::data ( ) const
inlineconstexprnoexcept

Definition at line 72 of file span.hpp.

72{ return first_elem; }

◆ empty() [1/2]

template<typename T , std::size_t Extent = dynamic_extent>
bool sysio::vm::span< T, Extent >::empty ( ) const
inlineconstexprnoexcept

Definition at line 75 of file span.hpp.

75{ return size() == 0; }
Here is the call graph for this function:

◆ empty() [2/2]

template<typename T , std::size_t Extent = dynamic_extent>
bool sysio::vm::span< T, Extent >::empty ( ) const
inlineconstexprnoexcept

Definition at line 75 of file span.hpp.

75{ return size() == 0; }
Here is the call graph for this function:

◆ end() [1/2]

template<typename T , std::size_t Extent = dynamic_extent>
iterator sysio::vm::span< T, Extent >::end ( ) const
inlineconstexprnoexcept

Definition at line 64 of file span.hpp.

64{ return last_elem; }

◆ end() [2/2]

template<typename T , std::size_t Extent = dynamic_extent>
iterator sysio::vm::span< T, Extent >::end ( ) const
inlineconstexprnoexcept

Definition at line 64 of file span.hpp.

64{ return last_elem; }

◆ first() [1/2]

template<typename T , std::size_t Extent = dynamic_extent>
span< T, dynamic_extent > sysio::vm::span< T, Extent >::first ( std::size_t len) const
inlineconstexpr

Definition at line 77 of file span.hpp.

77 {
78 SYS_VM_ASSERT(len <= size(), span_exception, "length overflows span");
79 return {first_elem, first_elem + len};
80 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ first() [2/2]

template<typename T , std::size_t Extent = dynamic_extent>
span< T, dynamic_extent > sysio::vm::span< T, Extent >::first ( std::size_t len) const
inlineconstexpr

Definition at line 77 of file span.hpp.

77 {
78 SYS_VM_ASSERT(len <= size(), span_exception, "length overflows span");
79 return {first_elem, first_elem + len};
80 }
Here is the call graph for this function:

◆ front() [1/2]

template<typename T , std::size_t Extent = dynamic_extent>
T & sysio::vm::span< T, Extent >::front ( ) const
inlineconstexpr

Definition at line 68 of file span.hpp.

68{ return *first_elem; }

◆ front() [2/2]

template<typename T , std::size_t Extent = dynamic_extent>
T & sysio::vm::span< T, Extent >::front ( ) const
inlineconstexpr

Definition at line 68 of file span.hpp.

68{ return *first_elem; }

◆ last() [1/2]

template<typename T , std::size_t Extent = dynamic_extent>
span< T, dynamic_extent > sysio::vm::span< T, Extent >::last ( std::size_t len) const
inlineconstexpr

Definition at line 82 of file span.hpp.

82 {
83 SYS_VM_ASSERT(len <= size(), span_exception, "length underflows span");
84 return {last_elem - len, last_elem};
85 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ last() [2/2]

template<typename T , std::size_t Extent = dynamic_extent>
span< T, dynamic_extent > sysio::vm::span< T, Extent >::last ( std::size_t len) const
inlineconstexpr

Definition at line 82 of file span.hpp.

82 {
83 SYS_VM_ASSERT(len <= size(), span_exception, "length underflows span");
84 return {last_elem - len, last_elem};
85 }
Here is the call graph for this function:

◆ operator=() [1/4]

template<typename T , std::size_t Extent = dynamic_extent>
span & sysio::vm::span< T, Extent >::operator= ( const span< T, Extent > & )
inlineconstexprdefault

◆ operator=() [2/4]

template<typename T , std::size_t Extent = dynamic_extent>
span & sysio::vm::span< T, Extent >::operator= ( const span< T, Extent > & )
inlineconstexprdefault

◆ operator=() [3/4]

template<typename T , std::size_t Extent = dynamic_extent>
span & sysio::vm::span< T, Extent >::operator= ( span< T, Extent > && )
inlineconstexprdefault

◆ operator=() [4/4]

template<typename T , std::size_t Extent = dynamic_extent>
span & sysio::vm::span< T, Extent >::operator= ( span< T, Extent > && )
inlineconstexprdefault

◆ operator[]() [1/2]

template<typename T , std::size_t Extent = dynamic_extent>
T & sysio::vm::span< T, Extent >::operator[] ( std::size_t n) const
inlineconstexpr

Definition at line 70 of file span.hpp.

70{ return first_elem[n]; }

◆ operator[]() [2/2]

template<typename T , std::size_t Extent = dynamic_extent>
T & sysio::vm::span< T, Extent >::operator[] ( std::size_t n) const
inlineconstexpr

Definition at line 70 of file span.hpp.

70{ return first_elem[n]; }

◆ rbegin() [1/2]

template<typename T , std::size_t Extent = dynamic_extent>
reverse_iterator sysio::vm::span< T, Extent >::rbegin ( ) const
inlineconstexprnoexcept

Definition at line 65 of file span.hpp.

65{ return reverse_iterator{last_elem}; }
std::reverse_iterator< iterator > reverse_iterator
Definition span.hpp:27

◆ rbegin() [2/2]

template<typename T , std::size_t Extent = dynamic_extent>
reverse_iterator sysio::vm::span< T, Extent >::rbegin ( ) const
inlineconstexprnoexcept

Definition at line 65 of file span.hpp.

65{ return reverse_iterator{last_elem}; }

◆ rend() [1/2]

template<typename T , std::size_t Extent = dynamic_extent>
reverse_iterator sysio::vm::span< T, Extent >::rend ( ) const
inlineconstexprnoexcept

Definition at line 66 of file span.hpp.

66{ return reverse_iterator{first_elem}; }

◆ rend() [2/2]

template<typename T , std::size_t Extent = dynamic_extent>
reverse_iterator sysio::vm::span< T, Extent >::rend ( ) const
inlineconstexprnoexcept

Definition at line 66 of file span.hpp.

66{ return reverse_iterator{first_elem}; }

◆ size() [1/2]

template<typename T , std::size_t Extent = dynamic_extent>
std::size_t sysio::vm::span< T, Extent >::size ( ) const
inlineconstexprnoexcept

Definition at line 73 of file span.hpp.

73{ return last_elem - first_elem; }
Here is the caller graph for this function:

◆ size() [2/2]

template<typename T , std::size_t Extent = dynamic_extent>
std::size_t sysio::vm::span< T, Extent >::size ( ) const
inlineconstexprnoexcept

Definition at line 73 of file span.hpp.

73{ return last_elem - first_elem; }

◆ size_bytes() [1/2]

template<typename T , std::size_t Extent = dynamic_extent>
std::size_t sysio::vm::span< T, Extent >::size_bytes ( ) const
inlineconstexprnoexcept

Definition at line 74 of file span.hpp.

74{ return size() * sizeof(T); }
#define T(meth, val, expected)
Here is the call graph for this function:

◆ size_bytes() [2/2]

template<typename T , std::size_t Extent = dynamic_extent>
std::size_t sysio::vm::span< T, Extent >::size_bytes ( ) const
inlineconstexprnoexcept

Definition at line 74 of file span.hpp.

74{ return size() * sizeof(T); }
Here is the call graph for this function:

◆ subspan() [1/2]

template<typename T , std::size_t Extent = dynamic_extent>
span< T, dynamic_extent > sysio::vm::span< T, Extent >::subspan ( std::size_t offset,
std::size_t len = dynamic_extent ) const
inlineconstexpr

Definition at line 87 of file span.hpp.

87 {
88 if(len == dynamic_extent) len = size() - offset;
89 SYS_VM_ASSERT(first_elem + offset + len <= last_elem, span_exception, "length overflows span");
90 return {first_elem + offset, len};
91 }
Here is the call graph for this function:

◆ subspan() [2/2]

template<typename T , std::size_t Extent = dynamic_extent>
span< T, dynamic_extent > sysio::vm::span< T, Extent >::subspan ( std::size_t offset,
std::size_t len = dynamic_extent ) const
inlineconstexpr

Definition at line 87 of file span.hpp.

87 {
88 if(len == dynamic_extent) len = size() - offset;
89 SYS_VM_ASSERT(first_elem + offset + len <= last_elem, span_exception, "length overflows span");
90 return {first_elem + offset, len};
91 }
Here is the call graph for this function:

Member Data Documentation

◆ extent

template<typename T , std::size_t Extent = dynamic_extent>
static constexpr std::size_t sysio::vm::span< T, Extent >::extent = Extent
staticconstexpr

Definition at line 28 of file span.hpp.


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