list::crend
역방향 목록에서 마지막 요소 다음에 나오는 위치의 주소를 지정하는 상수 반복기를 반환합니다.
const_reverse_iterator rend( ) const;
반환 값
역방향 list 클래스에서 마지막 요소 다음의 위치(역방향이 해제된 list의 첫 번째 요소 앞의 위치) 주소를 지정하는 const 역방향 양방향 반복기입니다.
설명
crend는 list에서 list::end이 사용되는 것처럼 역방향 목록에 사용됩니다.
반환 값이 crend이면 list 개체를 수정할 수 없습니다.
crend를 사용하여 역방향 반복기가 list 끝에 도달했는지 여부를 테스트할 수 있습니다.
crend에서 반환한 값은 역참조되지 않아야 합니다.
예제
// list_crend.cpp
// compile with: /EHsc
#include <list>
#include <iostream>
int main( )
{
using namespace std;
list <int> c1;
list <int>::const_reverse_iterator c1_crIter;
c1.push_back( 10 );
c1.push_back( 20 );
c1.push_back( 30 );
c1_crIter = c1.crend( );
c1_crIter --; // Decrementing a reverse iterator moves it forward in
// the list (to point to the first element here)
cout << "The first element in the list is: " << *c1_crIter << endl;
}
요구 사항
헤더: <list>
네임스페이스: std