function template
<valarray>
std::end (valarray)
| (1) | template <class T> /*unspecified1*/ end (valarray<T>& x); |
|---|---|
| (2) | template <class T> /*unspecified2*/ end (const valarray<T>& x); |
Iterator to end
Note that valarray objects have no member function end defined nor have iterator member types: The iterator returned is a random-access iterator of an unspecified type whose iterator_traits::value_type is T and its iterator_traits::reference type is T& for (1) and const T& for (2); It is a mutable iterator for (1), and a constant iterator for (2).
If the object is an empty valarray, the returned value compares equal to the one returned by begin for the same valarray.
This is an overload of end, defined in <iterator> (among other headers).
Parameters
- x
- A valarray object.
Return Value
A random-access iterator to the past-the-end element of x.Example
|
|
Output:
foo contains: 10 20 30 40 50
Complexity
Depends on library implementation, but likely constant.Iterator validity
No changes: Other valid iterators, references and sub-arrays keep their validity.Data races
The valarray is accessed, and in some library implementations, version (1) may also modify it (such as in copy-on-reference implementations).The iterator returned can be used to access or modify the elements of the valarray.
Exception safety
If the function implementation performs operations on the elements, and any such operation throws an exception, it causes undefined behavior.If the function needs to allocate storage and fails, it may throw an exception (such as bad_alloc), although this is not mandated.
See also
- end (valarray)
- Iterator to end (function template)