This documentation is archived and is not being maintained.


Tests if a queue is empty.

bool empty( ) const;

true if the queue is empty; false if the queue is nonempty.

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

int main( )
using namespace std;

   // Declares queues with default deque base container
   queue <int> q1, q2;

   q1.push( 1 );

   if ( q1.empty( ) )
      cout << "The queue q1 is empty." << endl;
      cout << "The queue q1 is not empty." << endl;

   if ( q2.empty( ) )
      cout << "The queue q2 is empty." << endl;
      cout << "The queue q2 is not empty." << endl;
The queue q1 is not empty. The queue q2 is empty.

Header: <queue>

Namespace: std