29 Numerics library [numerics]

29.7 Numeric arrays [numarray]

29.7.2 Class template valarray [template.valarray]

29.7.2.4 valarray element access [valarray.access]

const T& operator[](size_t n) const; T& operator[](size_t n);
Requires: n < size().
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 &a[i+j] == &a[i] + j evaluates to true for all size_­t i and size_­t j such that i+j < a.size().
The expression &a[i] != &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) ([valarray.members]) is called for that array or until the lifetime of that array ends, whichever happens first.