|
MIP_SDK
v4.0.0
MicroStrain Communications Library for embedded systems
|
Represents a view over a contiguous array of objects, similar to std::span, and is implemented as a pointer and length. More...
#include <array_view.hpp>
Public Types | |
| using | element_type = T |
| using | value_type = typename std::remove_cv< T >::type |
| using | difference_type = ptrdiff_t |
| using | pointer = T * |
| using | reference = T & |
| using | iterator = T * |
| using | const_pointer = const T * |
| using | const_reference = const T & |
| using | const_iterator = const T * |
Public Member Functions | |
| constexpr | ArrayView (pointer ptr) |
| constexpr pointer | begin () const noexcept |
| constexpr pointer | end () const noexcept |
| constexpr element_type | front () const noexcept |
| constexpr element_type | back () const noexcept |
| template<typename Index > | |
| constexpr reference | operator[] (Index idx) const noexcept |
| constexpr pointer | data () const noexcept |
| constexpr size_t | size () const noexcept |
| constexpr bool | empty () const noexcept |
| constexpr ArrayView< T, DYNAMIC_EXTENT > | subspan (size_t index, size_t length) const |
| constexpr ArrayView< T, DYNAMIC_EXTENT > | subspan (size_t index) const |
| template<size_t Offset, size_t Count = DYNAMIC_EXTENT> | |
| constexpr ArrayView< T, Count==DYNAMIC_EXTENT ? DYNAMIC_EXTENT :Extent-Count > | subspan () const |
| constexpr ArrayView< T, DYNAMIC_EXTENT > | first (size_t count) const |
| template<size_t Count> | |
| constexpr ArrayView< T, Count > | first () const |
| constexpr ArrayView< T, DYNAMIC_EXTENT > | last (size_t count) const |
| template<size_t Count> | |
| constexpr ArrayView< T, Count > | last () const |
| constexpr | operator pointer () const |
Static Public Attributes | |
| static constexpr size_t | extent = Extent |
It can be used as a function parameter to accommodate std::vector, std::array, and C-style arrays in one function signature. It's acceptable to pass ArrayViews by value, which is equivalent to passing separate pointer and length parameters. The underlying data would not be copied.
Note that because ArrayView doesn't store the underlying data, the original buffer must remain intact while the view is in use.
Some functions provide both pointer+length and ArrayView versions, while others provide just the ArrayView version. To call an ArrayView-only function with a pointer and length, just put braces around the pointer and length arguments. This will create an ArrayView implicitly with no performance impact: theFunctionToCall( {pointer, length} );
To pass an ArrayView to a function taking separate pointer and length parameters, call .data() and .size() for each, like so: theFunctionToCall( view.data(), view.size() );
This class is intended to be mostly compatible and interchangeable with std::span, but certain features from span may be missing and additional ones may be added.
| using microstrain::ArrayView< T, Extent >::element_type = T |
| using microstrain::ArrayView< T, Extent >::value_type = typename std::remove_cv<T>::type |
| using microstrain::ArrayView< T, Extent >::difference_type = ptrdiff_t |
| using microstrain::ArrayView< T, Extent >::pointer = T* |
| using microstrain::ArrayView< T, Extent >::reference = T& |
| using microstrain::ArrayView< T, Extent >::iterator = T* |
| using microstrain::ArrayView< T, Extent >::const_pointer = const T* |
| using microstrain::ArrayView< T, Extent >::const_reference = const T& |
| using microstrain::ArrayView< T, Extent >::const_iterator = const T* |
|
inlineexplicitconstexpr |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
staticconstexpr |
1.8.17