public member function

std::array::end

<array>
      iterator end() noexcept;
const_iterator end() const noexcept;
Return iterator to end
Returns an iterator pointing to the past-the-end element in the array container.

It is often used in combination with array::begin to specify a range including all the elements in the container.

Notice that, unlike member array::back, which returns a reference to the last element in the sequence, this function returns a random access iterator pointing to the element that would theoretically follow it.

The value returned shall not be dereferenced.

Parameters

none

Return Value

An iterator to the element past the end of the sequence.

Member types iterator and const_iterator are random access iterator types.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// array::end example
#include <iostream>
#include <array>

int main ()
{
  std::array<int,5> myarray = { 5, 19, 77, 34, 99 };

  std::cout << "myarray contains:";
  for ( auto it = myarray.begin(); it != myarray.end(); ++it )
    std::cout << " " << *it;

  std::cout << std::endl;

  return 0;
}


Output:
myarray contains: 5 19 77 34 99

Complexity

Constant.

Iterator validity

No changes.

See also