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 > 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 and its size. | |
template<size_t Size> | |
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. | |
Friends | |
bool | operator== (const ArrayView &lhs, const ArrayView &rhs) |
Equality operator. | |
bool | operator!= (const ArrayView &lhs, const ArrayView &rhs) |
Not equal operator. |
Detailed Description
template<typename T>
struct ble::ArrayView< T >
Immutable view to an array.
Array views encapsulate the pointer to an array and its size into a single object; 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().
- Template Parameters:
-
T type of objects held by the array.
Definition at line 54 of file ArrayView.h.
Constructor & Destructor Documentation
ArrayView | ( | ) |
Construct a view to an empty array.
Definition at line 61 of file ArrayView.h.
ArrayView | ( | T * | array_ptr, |
size_t | array_size | ||
) |
Construct an array view from a pointer to a buffer and its size.
- Parameters:
-
array_ptr Pointer to the array data array_size Number of elements of T present in the array.
Definition at line 72 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 86 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 132 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 142 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 108 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 122 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 94 of file ArrayView.h.
Friends And Related Function Documentation
Not equal operator.
- Parameters:
-
lhs Left hand side of the binary operation. rhs Right hand side of the binary operation.
- Returns:
- True if arrays in input do not have the same size or the same content and false otherwise.
Definition at line 178 of file ArrayView.h.
Equality operator.
- Parameters:
-
lhs Left hand side of the binary operation. rhs Right hand side of the binary operation.
- Returns:
- True if arrays in input have the same size and the same content and false otherwise.
Definition at line 156 of file ArrayView.h.
Generated on Tue Jul 12 2022 13:33:18 by
