Javatpoint Logo
Javatpoint Logo

C++ Queue empty() Function

C++ Queue empty() function is used for testing whether the container is empty or not. Sometimes before actually starting the work with the individual elements of the containers, it is more feasible to look up if the container is empty, so this function finds its usage in such cases.



There are no parameters. The function is only used to test for the emptiness of the container and hence takes no parameter.

Return value

If the container under reference is empty, then the method returns 'true' else returns 'false'.

Example 1


result is: 55

Example 2


The queue is  not empty


The complexity of the function is constant.

Data races

Only the container is accessed. By accessing the container, we come to know whether it is empty or not and based on that the value is returned.

Exception Safety

Guarantee as equivalent to the operations that are performed on the underlying container object is provided.

Next TopicC++ Queue

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA