共用方式為


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物件儲存格位址的發生的前一個項目。

範例

// iterator_op_gt.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 ( );
   
   cout << "The iterators rVPOS1 & rVPOS2 initially point to "
           << "the first element\n in the reversed sequence: "
           << *rVPOS1 << "." << endl;

   if ( rVPOS1 > rVPOS2 )
      cout << "The iterator rVPOS1 is greater than "
              << "the iterator rVPOS2." << endl;
   else
      cout << "The iterator rVPOS1 is less than or "
              << "equal to 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 "
              << "the iterator rVPOS2." << endl;
   else
      cout << "The iterator rVPOS1 is less than or "
              << "equal to the iterator rVPOS2." << endl;
}
  
  
  
  
  

需求

標題: <iterator>

命名空間: std

請參閱

參考

標準樣板程式庫