Compartir a través de


queue::empty

Tests if a queue is empty.

bool empty( ) const;

Return Value

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

Example

// 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;
   else
      cout << "The queue q1 is not empty." << endl;

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

Requirements

Header: <queue>

Namespace: std

See Also

Reference

queue Class

queue Functions

Standard Template Library

Other Resources

queue Members