list::crend
傳回處理成功最後一個項目的位置會反轉的清單的 const Iterator。
const_reverse_iterator rend( ) const;
傳回值
解決成功最後一個項目的位置會以反轉的 list Class 的常數反向雙向 Iterator (在 unreversed list的第一個項目之前) 的位置。
備註
無效 list::end 搭配 list,crend 搭配反向排列的清單。
crend的傳回值,因此無法修改 list 物件。
crend 可用來測試反向 Iterator 是否已到達其 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