다음을 통해 공유


list::end

목록에서 마지막 요소 다음에 나오는 위치의 주소를 지정하는 반복기를 반환합니다.

const_iterator end( ) const; iterator end( );

반환 값

목록에서 마지막 요소 다음에 나오는 위치의 주소를 지정하는 양방향 반복기입니다. 목록이 비어 있으면 list::end == list::begin입니다.

설명

end는 반복기가 목록의 끝에 도달했는지 여부를 테스트하는 데 사용됩니다.

예제

// list_end.cpp
// compile with: /EHsc
#include <list>
#include <iostream>

int main( ) 
{
   using namespace std;
   list <int> c1;
   list <int>::iterator c1_Iter;
   
   c1.push_back( 10 );
   c1.push_back( 20 );
   c1.push_back( 30 );

   c1_Iter = c1.end( );
   c1_Iter--;
   cout << "The last integer of c1 is " << *c1_Iter << endl;

   c1_Iter--;
   *c1_Iter = 400;
   cout << "The new next-to-last integer of c1 is "
        << *c1_Iter << endl;

   // If a const iterator had been declared instead with the line:
   // list <int>::const_iterator c1_Iter;
   // an error would have resulted when inserting the 400

   cout << "The list is now:";
   for ( c1_Iter = c1.begin( ); c1_Iter != c1.end( ); c1_Iter++ )
      cout << " " << *c1_Iter;
}
  

요구 사항

헤더: <list>

네임스페이스: std

참고 항목

참조

list 클래스

표준 템플릿 라이브러리