Поделиться через


map::cend

Возвращает итератор, -- элемент const.

const_iterator cend( ) const;

Возвращаемое значение

Итератор, -- элемент.Если map Class пусто, то map::cend() == map::begin().

Заметки

cend используется для проверки достиг конца map ли итератор.

Значение, возвращаемое cend не должно быть разыменованно.

Пример

// map_cend.cpp
// compile with: /EHsc
#include <map>
#include <iostream>

int main( )
{
   using namespace std;
   map <int, int> m1;

   map <int, int> :: const_iterator m1_cIter;
   typedef pair <int, int> Int_Pair;

   m1.insert ( Int_Pair ( 1, 10 ) );
   m1.insert ( Int_Pair ( 2, 20 ) );
   m1.insert ( Int_Pair ( 3, 30 ) );

   m1_cIter = m1.cend( );
   m1_cIter--;
   cout << "The value of the last element of m1 is:\n" 
        << m1_cIter -> second << endl;
}
  

Требования

заголовок: <map>

std пространство имен:

См. также

Ссылки

map Class

Стандартная библиотека шаблонов