Share via


list::crend

逆順のリスト内の最後の要素の次の位置を指す定数反復子を返します。

const_reverse_iterator rend( ) const;

戻り値

逆順の list クラス 内の最後の要素の次の場所 (通常の順序の list 内の最初の要素の前の場所) を指す定数逆順双方向反復子。

解説

crend は、list::end が list で使用されるように、逆順のリストで使用されます。

戻り値が 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

参照

関連項目

list クラス

標準テンプレート ライブラリ