次の方法で共有


operator>= (<iterator>)

演算子の左側の反復子オブジェクトが右側の反復子オブジェクトに値以上でテスト。

template<class RandomIterator>
   bool operator>=(
      const reverse_iterator<RandomIterator>& _Left,
      const reverse_iterator<RandomIterator>& _Right
   );

パラメーター

  • _Left
    型の反復子オブジェクト。

  • _Right
    型の反復子オブジェクト。

戻り値

式の左辺の反復子が式の右側の反復子の値以上でtrue ; 右側の反復子である場合よりも小さい false

解説

1 回の反復子オブジェクトは同じ要素またはコンテナーに他の反復子オブジェクトによってアドレス要素より後に実行する要素を別のアドレスに大きいか等しい。1 回の反復子オブジェクトは、コンテナーに他の反復子オブジェクトによってアドレス要素よりも前に発生する要素を指定する他方の値より小さい。

使用例

// iterator_op_ge.cpp
// compile with: /EHsc
#include <iterator>
#include <vector>
#include <iostream>

int main( )
{
   using namespace std;
   int i;

   vector<int> vec;
   for (i = 0 ; i < 6 ; ++i )  {
      vec.push_back ( 2 * i );
      }
   
   vector <int>::iterator vIter;

   cout << "The initial vector vec is: ( ";
   for ( vIter = vec.begin( ) ; vIter != vec.end( ); vIter++)
      cout << *vIter << " ";
   cout << ")." << endl;

   vector <int>::reverse_iterator rVPOS1 = vec.rbegin ( ), 
           rVPOS2 = vec.rbegin ( ) + 1;
   
   cout << "The iterator rVPOS1 initially points to the "
           << "first element\n in the reversed sequence: "
           << *rVPOS1 << "." << endl;

   cout << "The iterator rVPOS2 initially points to the "
           << "second element\n in the reversed sequence: "
           << *rVPOS2 << "." << endl;

   if ( rVPOS1 >= rVPOS2 )
      cout << "The iterator rVPOS1 is greater than or "
              << "equal to the iterator rVPOS2." << endl;
   else
      cout << "The iterator rVPOS1 is less than "
              << "the iterator rVPOS2." << endl;

   rVPOS1++;
   cout << "The iterator rVPOS1 now points to the second "
           << "element\n in the reversed sequence: "
           << *rVPOS1 << "." << endl;

   if ( rVPOS1 >= rVPOS2 )
      cout << "The iterator rVPOS1 is greater than or "
              << "equal to the iterator rVPOS2." << endl;
   else
      cout << "The iterator rVPOS1 is less than "
              << "the iterator rVPOS2." << endl;
}
  
  
  
  
  
  

必要条件

ヘッダー: <iterator>

名前空間: std

参照

関連項目

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