public member function
<array>
std::array::data
value_type* data() noexcept;const value_type* data() const noexcept;
Get pointer to data
Because elements in the array are stored in contiguous storage locations, the pointer retrieved can be offset to access any element in the array.
Parameters
noneReturn Value
Pointer to the data contained by the array object.
If the array object is const-qualified, the function returns a pointer to const value_type. Otherwise, it returns a pointer to value_type.
Member type
value_type is the type of the elements in the container, defined in array as an alias of its first template parameter (T).Example
|
|
Output:
Complexity
Constant.Iterator validity
No changes.Data races
No contained elements are directly accessed by the call, but the pointer returned can be used to access or modify elements. Concurrently accessing or modifying different elements is safe.Exception safety
No-throw guarantee: this member function never throws exceptions.See also
- array::begin
- Return iterator to beginning (public member function)
- array::front
- Access first element (public member function)
- array::operator[]
- Access element (public member function)
- array::fill
- Fill array with value (public member function)