共用方式為


operator== (<queue>)

測試,如果左側的佇列物件等於右邊的佇列物件。

bool operator==(
   const queue <Type, Container>& _Left,
   const queue <Type, Container>& _Right,
);

參數

  • _Left
    型別 queue物件。

  • _Right
    型別 queue物件。

傳回值

true ,如果佇列不相等, false ,如果佇列是相等的。

備註

在佇列中物件之間的比較可能會依據其項目比較配對方式。 兩個佇列長度相等的序列,則具有相同的元素數目,且其元素具有相同的值。 否則就是不相等。

範例

// queue_op_eq.cpp
// compile with: /EHsc
#include <queue>
#include <list>
#include <iostream>

int main( )
{
   using namespace std;

   // Declares queues with list base containers
   queue <int, list<int> > q1, q2, q3;

   // The following line would have caused an error because vector 
   // does not support pop_front( ) and so cannot be adapted
   // by queue as a base container
   // queue <int, vector<int> > q1, q2, q3;

   q1.push( 1 );
   q2.push( 2 );
   q3.push( 1 );

   if ( q1 != q2 )
      cout << "The queues q1 and q2 are not equal." << endl;
   else
      cout << "The queues q1 and q2 are equal." << endl;


   if ( q1 != q3 )
      cout << "The queues q1 and q3 are not equal." << endl;
   else
      cout << "The queues q1 and q3 are equal." << endl;
}
  
  

需求

標題: <queue>

命名空間: std

請參閱

參考

標準樣板程式庫