共用方式為


operator>= (<iterator>)

測試,如果左側的 Iterator 物件大於或等於右邊的 Iterator 物件。

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

參數

  • _Left
    型別之物件。

  • _Right
    型別之物件。

傳回值

true ,如果運算式的左側 Iterator 大於或等於 Iterator 在運算式右邊; false ,如果大於右邊的 Iterator 小於。

備註

Iterator 物件大於或等於另一個值,則它會說明相同項目或在容器使用另一個 Iterator 物件項目的基底位址 (Base Address) 之後的項目。Iterator 大於另一個物件的,則它會處理已在容器使用另一個 Iterator 物件儲存格位址的發生的前一個項目。

範例

// 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

請參閱

參考

標準樣板程式庫