返回解决成功最后一个元素的位置在反向列表的常量迭代器。
const_reverse_iterator rend( ) const;
返回值
解决成功最后一个元素的位置。是相反的 list Class 的常量反转双向迭代器(在前面unreversed list的第一个元素)的位置。
备注
正 list::end 使用 list,crend 使用反向列表。
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