Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
ArrayView< T, Size > Struct Template Reference
Immutable view to an array. More...
#include <ArrayView.h>
Public Member Functions | |
ArrayView () | |
Construct a view to an empty array. | |
ArrayView (T *array_ptr, size_t array_size) | |
Construct an array view from a pointer to a buffer. | |
ArrayView (T(&elements)[Size]) | |
Construct an array view from the reference to an array. | |
size_t | size () const |
Return the size of the array viewed. | |
T & | operator[] (size_t index) |
Access to a mutable element of the array. | |
const T & | operator[] (size_t index) const |
Access to an immutable element of the array. | |
T * | data () |
Get the raw pointer to the array. | |
const T * | data () const |
Get the raw const pointer to the array. |
Detailed Description
template<typename T, ptrdiff_t Size = ARRAY_VIEW_DYNAMIC_SIZE>
struct ble::ArrayView< T, Size >
Immutable view to an array.
Array views encapsulate the pointer to an array and its size into a single object or type; however, it does not manage the lifetime of the array viewed. You can use instances of ArrayView to replace the traditional pair of pointer and size arguments in function calls.
You can use the size member function to query the number of elements present in the array, and overloads of the subscript operator allow code using this object to access to the content of the array viewed.
- Note:
- You can create ArrayView instances with the help of the function template make_ArrayView() and make_const_ArrayView().
- ArrayView<T, Size> objects can be implicitly converted to ArrayView<T> objects where required.
- Template Parameters:
-
T type of objects held by the array. Size The size of the array viewed. The default value ARRAY_VIEW_DYNAMIC_SIZE is special as it allows construction of ArrayView objects of any size (set at runtime).
Definition at line 70 of file ArrayView.h.
Constructor & Destructor Documentation
ArrayView | ( | ) |
Construct a view to an empty array.
Definition at line 79 of file ArrayView.h.
ArrayView | ( | T * | array_ptr, |
size_t | array_size | ||
) |
Construct an array view from a pointer to a buffer.
- Parameters:
-
array_ptr Pointer to the array data array_size Number of elements of T present in the array.
Definition at line 90 of file ArrayView.h.
ArrayView | ( | T(&) | elements[Size] ) |
Construct an array view from the reference to an array.
- Parameters:
-
elements Reference to the array viewed.
- Template Parameters:
-
Size Number of elements of T presents in the array.
Definition at line 105 of file ArrayView.h.
Member Function Documentation
T* data | ( | ) |
Get the raw pointer to the array.
- Returns:
- The raw pointer to the array.
Definition at line 151 of file ArrayView.h.
const T* data | ( | ) | const |
Get the raw const pointer to the array.
- Returns:
- The raw pointer to the array.
Definition at line 161 of file ArrayView.h.
const T& operator[] | ( | size_t | index ) | const |
Access to an immutable element of the array.
- Parameters:
-
index Element index to access.
- Returns:
- A const reference to the element at the index specified in input.
- Precondition:
- index shall be less than size().
Definition at line 141 of file ArrayView.h.
T& operator[] | ( | size_t | index ) |
Access to a mutable element of the array.
- Parameters:
-
index Element index to access.
- Returns:
- A reference to the element at the index specified in input.
- Precondition:
- index shall be less than size().
Definition at line 127 of file ArrayView.h.
size_t size | ( | ) | const |
Return the size of the array viewed.
- Returns:
- The number of elements present in the array viewed.
Definition at line 113 of file ArrayView.h.
Generated on Tue Aug 9 2022 00:37:37 by
