26 Numerics library [numerics]

26.7 Numeric arrays [numarray]

26.7.2 Class template valarray [template.valarray]

26.7.2.4 Element access [valarray.access]

const T& operator[](size_t n) const; T& operator[](size_t n);
Preconditions: n < size() is true.
Returns: A reference to the corresponding element of the array.
Note
:
The expression (a[i] = q, a[i]) == q evaluates to true for any non-constant valarray<T> a, any T q, and for any size_­t i such that the value of i is less than the length of a.
— end note
 ]
Remarks: The expression addressof(a[i+j]) == addressof(a[i]) + j evaluates to true for all size_­t i and size_­t j such that i+j < a.size().
The expression addressof(a[i]) != addressof(b[j]) evaluates to true for any two arrays a and b and for any size_­t i and size_­t j such that i < a.size() and j < b.size().
Note
:
This property indicates an absence of aliasing and may be used to advantage by optimizing compilers.
Compilers may take advantage of inlining, constant propagation, loop fusion, tracking of pointers obtained from operator new, and other techniques to generate efficient valarrays.
— end note
 ]
The reference returned by the subscript operator for an array shall be valid until the member function resize(size_­t, T) is called for that array or until the lifetime of that array ends, whichever happens first.