Share via


vector::cend

Returns the past-the-end iterator.

const_iterator cend( ) const;

Return Value

The const past-the-end iterator for the vector Class. If the vector is empty, vector::cend() == vector::cbegin().

Remarks

With the return value of cend (suitably decremented), the vector object cannot be modified.

Example

// vector_cend.cpp
// compile with: /EHsc
#include <vector>
#include <iostream>
int main( )
{
   using namespace std;
   vector <int> v1;
   vector <int>::const_iterator v1_Iter;
   
   v1.push_back( 1 );
   v1.push_back( 2 );

   for ( v1_Iter = v1.cbegin( ) ; v1_Iter != v1.cend( ) ; v1_Iter++ )
      cout << *v1_Iter << endl;
}
1
2

Requirements

Header: <vector>

Namespace: std

See Also

Reference

vector Class

Standard Template Library