MIP_SDK
v3.0.0-208-gdb90bae
MicroStrain Communications Library for embedded systems
|
Go to the documentation of this file.
3 #ifdef MICROSTRAIN_USE_STD_SPAN
10 static inline constexpr
size_t DYNAMIC_EXTENT = std::dynamic_extent;
12 template<
class T,
size_t Size=DYNAMIC_EXTENT>
13 using Span = std::span<T, Size>;
17 #else // MICROSTRAIN_USE_STD_SPAN
19 #include <type_traits>
27 static constexpr
size_t DYNAMIC_EXTENT = SIZE_MAX;
40 template<
class T,
size_t Extent=DYNAMIC_EXTENT>
43 static constexpr
size_t extent = Extent;
68 [[nodiscard]] constexpr
size_t size() const noexcept {
return extent; }
69 [[nodiscard]] constexpr
bool empty() const noexcept {
return extent == 0; }
73 template<
size_t Offset,
size_t Count = DYNAMIC_EXTENT>
74 [[nodiscard]] constexpr
Span<T, Count == DYNAMIC_EXTENT ? DYNAMIC_EXTENT : Extent-Count>
subspan()
const {
return {m_ptr+Offset}; }
77 template<
size_t Count>
78 [[nodiscard]] constexpr
Span<T, Count> first()
const { static_assert(Count<=Extent,
"Count out of range");
return {m_ptr}; }
81 template<
size_t Count>
82 [[nodiscard]] constexpr
Span<T, Count> last()
const { static_assert(Count<=Extent,
"Count out of range");
return {m_ptr+(Extent-Count)}; }
90 struct Span<T, DYNAMIC_EXTENT>
102 constexpr
Span() =
default;
103 constexpr
Span(
pointer ptr,
size_t cnt) : m_ptr(ptr), m_cnt(cnt) {}
105 constexpr
Span(
const T (&arr)[N]) : m_ptr(arr), m_cnt(N) {}
108 constexpr
pointer end() const noexcept {
return m_ptr+m_cnt; }
118 [[nodiscard]] constexpr
size_t size() const noexcept {
return m_cnt; }
119 [[nodiscard]] constexpr
bool empty() const noexcept {
return m_cnt == 0; }
123 template<
size_t Offset,
size_t Count = DYNAMIC_EXTENT>
127 template<
size_t Count>
131 template<
size_t Count>
142 #endif // MICROSTRAIN_USE_STD_SPAN
constexpr pointer data() const noexcept
Definition: span.hpp:66
constexpr Span< T, DYNAMIC_EXTENT > subspan(size_t index) const
Definition: span.hpp:72
constexpr Span(pointer ptr)
Definition: span.hpp:55
T * pointer
Definition: span.hpp:48
T element_type
Definition: span.hpp:92
constexpr Span< T, DYNAMIC_EXTENT > last(size_t count) const
Definition: span.hpp:130
constexpr Span< T, DYNAMIC_EXTENT > first(size_t count) const
Definition: span.hpp:76
constexpr Span< T, DYNAMIC_EXTENT > subspan(size_t index, size_t length) const
Definition: span.hpp:121
constexpr element_type front() const noexcept
Definition: span.hpp:60
constexpr Span< T, Count > last() const
Definition: span.hpp:132
T * iterator
Definition: span.hpp:97
constexpr Span< T, DYNAMIC_EXTENT > subspan(size_t index, size_t length) const
Definition: span.hpp:71
constexpr element_type front() const noexcept
Definition: span.hpp:110
constexpr size_t size() const noexcept
Definition: span.hpp:68
const T * const_pointer
Definition: span.hpp:98
constexpr const_reference operator[](size_t idx) const noexcept
Definition: span.hpp:64
constexpr pointer end() const noexcept
Definition: span.hpp:108
ptrdiff_t difference_type
Definition: span.hpp:94
Implementation of std::span from C++20.
Definition: span.hpp:41
constexpr bool empty() const noexcept
Definition: span.hpp:119
T * pointer
Definition: span.hpp:95
typename std::remove_cv< T >::type value_type
Definition: span.hpp:93
constexpr Span< T, Count > first() const
Definition: span.hpp:78
constexpr Span< T, Count==DYNAMIC_EXTENT ? DYNAMIC_EXTENT :Extent-Count > subspan() const
Definition: span.hpp:74
constexpr Span(const T(&arr)[N])
Definition: span.hpp:105
const T & const_reference
Definition: span.hpp:99
constexpr pointer data() const noexcept
Definition: span.hpp:116
constexpr pointer begin() const noexcept
Definition: span.hpp:57
const T * const_iterator
Definition: span.hpp:100
constexpr Span< T, Count > last() const
Definition: span.hpp:82
constexpr Span< T, DYNAMIC_EXTENT > subspan(size_t index) const
Definition: span.hpp:122
const const mip::metadata::ParameterInfo & const_reference
Definition: span.hpp:52
constexpr pointer begin() const noexcept
Definition: span.hpp:107
const const mip::metadata::ParameterInfo * const_pointer
Definition: span.hpp:51
constexpr size_t size() const noexcept
Definition: span.hpp:118
ptrdiff_t difference_type
Definition: span.hpp:47
constexpr reference operator[](size_t idx) noexcept
Definition: span.hpp:63
constexpr bool empty() const noexcept
Definition: span.hpp:69
constexpr pointer end() const noexcept
Definition: span.hpp:58
constexpr Span< T, Count > first() const
Definition: span.hpp:128
constexpr Span< T, DYNAMIC_EXTENT > first(size_t count) const
Definition: span.hpp:126
constexpr element_type back() const noexcept
Definition: span.hpp:111
T & reference
Definition: span.hpp:96
constexpr Span< T, Count > subspan() const
Definition: span.hpp:124
constexpr element_type back() const noexcept
Definition: span.hpp:61
constexpr Span< T, DYNAMIC_EXTENT > last(size_t count) const
Definition: span.hpp:80
typename std::remove_cv< const mip::metadata::ParameterInfo >::type value_type
Definition: span.hpp:46
static constexpr size_t extent
Definition: span.hpp:43
constexpr Span(pointer ptr, size_t cnt)
Definition: span.hpp:103
constexpr reference operator[](size_t idx) noexcept
Definition: span.hpp:113
constexpr const_reference operator[](size_t idx) const noexcept
Definition: span.hpp:114
Definition: embedded_time.h:8
const const mip::metadata::ParameterInfo * const_iterator
Definition: span.hpp:53