I realized that you were asking: what is the size of the memory occupied by the ensemble of the element array<value_type,N> arr , which is between arr.begin() and arr.end() ?
The answer is sizeof(value_type)*N , this is specified in the standard, but some processing is required to get this result.
In the C ++ standard [dcl.array] (this is about (c-) an array not std::array ):
An array type object contains an adjacent nonempty set of N subobjects of type T.
in [expr.add] (here also the term array refers to a (c-) array):
When an expression that has an integral type is added or subtracted from the pointer, the result is the type of the operand of the pointer. If the expression P points to the element x [i] of the object of the array x with n elements, 86 expressions P + J and J + P (where J has the value j) indicate the (possibly hypothetical) element x [i + j], if 0 ≤ i + j ≤ n; otherwise, the behavior is undefined. Similarly, the expression P - J indicates a (possibly hypothetical) element x [i - j] if 0 ≤ i - j ≤ n; otherwise, the behavior is undefined.
And in [array.data] (here the term array refers to std::array ):
constexpr T* data() noexcept; constexpr const T* data() const noexcept;
Returns: a pointer such that data () == addressof (front ()) and [data (), data () + size ()) is a valid range.
So, data() returns a valid range for the std::array element, this range is iterated using a pointer to value_type, so it follows the arithmetic of the pointer, which follows the rule for (c-) indexing the array and the elements a (c-) array are adjacent . QED
source share