In C++, the deque::empty() function is used to check whether a deque container is empty or not. If the deque contains no elements, the function returns true; otherwise, it returns false. This function is useful before performing operations like deletion or accessing elements from a deque. It helps avoid errors when working with empty containers.
It has the following syntax:
It does not contain any parameter.
It does not return any value.
Here, we are going to discuss several examples to demonstrate the deque empty() function.
This example demonstrates how to check whether a deque contains elements using the empty() function.
Output:
Deque is not empty
Explanation:
In this example, empty() function determines that the deque is not empty. Therefore, it returns false.
This example demonstrates how to verify whether a deque is empty using the empty() function.
Output:
Deque is empty
Explanation:
In this example, empty() function determines that the deque is empty. Therefore, it returns true.
This example demonstrates how to use the empty() function after removing all elements from a deque.
Output:
Deque is empty
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India