MIP_SDK
v3.0.0
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>
26 static constexpr
size_t DYNAMIC_EXTENT = -1;
39 template<
class T,
size_t Extent=DYNAMIC_EXTENT>
42 static constexpr
size_t extent = Extent;
65 [[nodiscard]] constexpr
size_t size() const noexcept {
return extent; }
66 [[nodiscard]] constexpr
bool empty() const noexcept {
return extent == 0; }
70 template<
size_t Offset,
size_t Count = DYNAMIC_EXTENT>
71 [[nodiscard]] constexpr
Span<T, Count == DYNAMIC_EXTENT ? DYNAMIC_EXTENT : Extent-Count>
subspan()
const {
return {m_ptr+Offset}; }
79 struct Span<T, DYNAMIC_EXTENT>
89 constexpr
Span() =
default;
90 constexpr
Span(
pointer ptr,
size_t cnt) : m_ptr(ptr), m_cnt(cnt) {}
92 constexpr
Span(
const T (&arr)[N]) : m_ptr(arr), m_cnt(N) {}
95 constexpr
pointer end() const noexcept {
return m_ptr+m_cnt; }
105 [[nodiscard]] constexpr
size_t size() const noexcept {
return m_cnt; }
106 [[nodiscard]] constexpr
bool empty() const noexcept {
return m_cnt == 0; }
110 template<
size_t Offset,
size_t Count = DYNAMIC_EXTENT>
121 #endif // MICROSTRAIN_USE_STD_SPAN
constexpr pointer data() const noexcept
Definition: span.hpp:63
constexpr Span< T, DYNAMIC_EXTENT > subspan(size_t index) const
Definition: span.hpp:69
constexpr Span(pointer ptr)
Definition: span.hpp:52
T * pointer
Definition: span.hpp:47
T element_type
Definition: span.hpp:81
constexpr Span< T, DYNAMIC_EXTENT > subspan(size_t index, size_t length) const
Definition: span.hpp:108
constexpr element_type front() const noexcept
Definition: span.hpp:57
constexpr Span< T, DYNAMIC_EXTENT > subspan(size_t index, size_t length) const
Definition: span.hpp:68
constexpr element_type front() const noexcept
Definition: span.hpp:97
constexpr size_t size() const noexcept
Definition: span.hpp:65
const T * const_pointer
Definition: span.hpp:86
constexpr const_reference operator[](size_t idx) const noexcept
Definition: span.hpp:61
constexpr pointer end() const noexcept
Definition: span.hpp:95
ptrdiff_t difference_type
Definition: span.hpp:83
Implementation of std::span from C++20.
Definition: span.hpp:40
constexpr bool empty() const noexcept
Definition: span.hpp:106
T * pointer
Definition: span.hpp:84
typename std::remove_cv< T >::type value_type
Definition: span.hpp:82
constexpr Span< T, Count==DYNAMIC_EXTENT ? DYNAMIC_EXTENT :Extent-Count > subspan() const
Definition: span.hpp:71
constexpr Span(const T(&arr)[N])
Definition: span.hpp:92
const T & const_reference
Definition: span.hpp:87
constexpr pointer data() const noexcept
Definition: span.hpp:103
constexpr pointer begin() const noexcept
Definition: span.hpp:54
constexpr Span< T, DYNAMIC_EXTENT > subspan(size_t index) const
Definition: span.hpp:109
const const mip::metadata::ParameterInfo & const_reference
Definition: span.hpp:50
constexpr pointer begin() const noexcept
Definition: span.hpp:94
const const mip::metadata::ParameterInfo * const_pointer
Definition: span.hpp:49
constexpr size_t size() const noexcept
Definition: span.hpp:105
ptrdiff_t difference_type
Definition: span.hpp:46
constexpr reference operator[](size_t idx) noexcept
Definition: span.hpp:60
constexpr bool empty() const noexcept
Definition: span.hpp:66
constexpr pointer end() const noexcept
Definition: span.hpp:55
constexpr element_type back() const noexcept
Definition: span.hpp:98
T & reference
Definition: span.hpp:85
constexpr Span< T, Count > subspan() const
Definition: span.hpp:111
constexpr element_type back() const noexcept
Definition: span.hpp:58
typename std::remove_cv< const mip::metadata::ParameterInfo >::type value_type
Definition: span.hpp:45
static constexpr size_t extent
Definition: span.hpp:42
constexpr Span(pointer ptr, size_t cnt)
Definition: span.hpp:90
constexpr reference operator[](size_t idx) noexcept
Definition: span.hpp:100
constexpr const_reference operator[](size_t idx) const noexcept
Definition: span.hpp:101
Definition: embedded_time.h:8