MIP_SDK
v3.0.0-187-g93c7302
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;
66 [[nodiscard]] constexpr
size_t size() const noexcept {
return extent; }
67 [[nodiscard]] constexpr
bool empty() const noexcept {
return extent == 0; }
71 template<
size_t Offset,
size_t Count = DYNAMIC_EXTENT>
72 [[nodiscard]] constexpr
Span<T, Count == DYNAMIC_EXTENT ? DYNAMIC_EXTENT : Extent-Count>
subspan()
const {
return {m_ptr+Offset}; }
75 template<
size_t Count>
76 [[nodiscard]] constexpr
Span<T, Count> first()
const { static_assert(Count<=Extent,
"Count out of range");
return {m_ptr}; }
79 template<
size_t Count>
80 [[nodiscard]] constexpr
Span<T, Count> last()
const { static_assert(Count<=Extent,
"Count out of range");
return {m_ptr+(Extent-Count)}; }
88 struct Span<T, DYNAMIC_EXTENT>
98 constexpr
Span() =
default;
99 constexpr
Span(
pointer ptr,
size_t cnt) : m_ptr(ptr), m_cnt(cnt) {}
101 constexpr
Span(
const T (&arr)[N]) : m_ptr(arr), m_cnt(N) {}
104 constexpr
pointer end() const noexcept {
return m_ptr+m_cnt; }
114 [[nodiscard]] constexpr
size_t size() const noexcept {
return m_cnt; }
115 [[nodiscard]] constexpr
bool empty() const noexcept {
return m_cnt == 0; }
119 template<
size_t Offset,
size_t Count = DYNAMIC_EXTENT>
123 template<
size_t Count>
127 template<
size_t Count>
138 #endif // MICROSTRAIN_USE_STD_SPAN
constexpr pointer data() const noexcept
Definition: span.hpp:64
constexpr Span< T, DYNAMIC_EXTENT > subspan(size_t index) const
Definition: span.hpp:70
constexpr Span(pointer ptr)
Definition: span.hpp:53
T * pointer
Definition: span.hpp:48
T element_type
Definition: span.hpp:90
constexpr Span< T, DYNAMIC_EXTENT > last(size_t count) const
Definition: span.hpp:126
constexpr Span< T, DYNAMIC_EXTENT > first(size_t count) const
Definition: span.hpp:74
constexpr Span< T, DYNAMIC_EXTENT > subspan(size_t index, size_t length) const
Definition: span.hpp:117
constexpr element_type front() const noexcept
Definition: span.hpp:58
constexpr Span< T, Count > last() const
Definition: span.hpp:128
constexpr Span< T, DYNAMIC_EXTENT > subspan(size_t index, size_t length) const
Definition: span.hpp:69
constexpr element_type front() const noexcept
Definition: span.hpp:106
constexpr size_t size() const noexcept
Definition: span.hpp:66
const T * const_pointer
Definition: span.hpp:95
constexpr const_reference operator[](size_t idx) const noexcept
Definition: span.hpp:62
constexpr pointer end() const noexcept
Definition: span.hpp:104
ptrdiff_t difference_type
Definition: span.hpp:92
Implementation of std::span from C++20.
Definition: span.hpp:41
constexpr bool empty() const noexcept
Definition: span.hpp:115
T * pointer
Definition: span.hpp:93
typename std::remove_cv< T >::type value_type
Definition: span.hpp:91
constexpr Span< T, Count > first() const
Definition: span.hpp:76
constexpr Span< T, Count==DYNAMIC_EXTENT ? DYNAMIC_EXTENT :Extent-Count > subspan() const
Definition: span.hpp:72
constexpr Span(const T(&arr)[N])
Definition: span.hpp:101
const T & const_reference
Definition: span.hpp:96
constexpr pointer data() const noexcept
Definition: span.hpp:112
constexpr pointer begin() const noexcept
Definition: span.hpp:55
constexpr Span< T, Count > last() const
Definition: span.hpp:80
constexpr Span< T, DYNAMIC_EXTENT > subspan(size_t index) const
Definition: span.hpp:118
const const mip::metadata::ParameterInfo & const_reference
Definition: span.hpp:51
constexpr pointer begin() const noexcept
Definition: span.hpp:103
const const mip::metadata::ParameterInfo * const_pointer
Definition: span.hpp:50
constexpr size_t size() const noexcept
Definition: span.hpp:114
ptrdiff_t difference_type
Definition: span.hpp:47
constexpr reference operator[](size_t idx) noexcept
Definition: span.hpp:61
constexpr bool empty() const noexcept
Definition: span.hpp:67
constexpr pointer end() const noexcept
Definition: span.hpp:56
constexpr Span< T, Count > first() const
Definition: span.hpp:124
constexpr Span< T, DYNAMIC_EXTENT > first(size_t count) const
Definition: span.hpp:122
constexpr element_type back() const noexcept
Definition: span.hpp:107
T & reference
Definition: span.hpp:94
constexpr Span< T, Count > subspan() const
Definition: span.hpp:120
constexpr element_type back() const noexcept
Definition: span.hpp:59
constexpr Span< T, DYNAMIC_EXTENT > last(size_t count) const
Definition: span.hpp:78
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:99
constexpr reference operator[](size_t idx) noexcept
Definition: span.hpp:109
constexpr const_reference operator[](size_t idx) const noexcept
Definition: span.hpp:110
Definition: embedded_time.h:8