C++ valarray Library - Function end
Description
It returns an iterator pointing to the past-the-end element in the valarray x.
Declaration
Following is the declaration for std::valarray::end function.
template <class T> /*unspecified1*/ end (valarray<T>& x);
C++11
template <class T> /*unspecified1*/ end (valarray<T>& x);
Parameters
x − It is a valarray objects.
Return Value
It returns an iterator pointing to the first element in the valarray x.
Exceptions
Basic guarantee − if any operation performed on the elements throws an exception.
Data races
All elements effectively copied are accessed.
Example
In below example explains about std::valarray::end function.
#include <iostream>
#include <valarray>
int main () {
std::valarray<int> sam {10,20,30,40,50};
std::cout << "sam contains:";
for (auto it = begin(sam); it!=end(sam); ++it)
std::cout << ' ' << *it;
std::cout << '\n';
return 0;
}
Let us compile and run the above program, this will produce the following result −
sam contains: 10 20 30 40 50
valarray.htm