Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All


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

© 2015 Microsoft