Namespaces
Variants

std::queue<T,Container>::empty

From cppreference.com

[edit template]
 
 
 
 
bool empty() const;
(constexpr since C++26)

Checks if the underlying container has no elements. Equivalent to: return c.empty().

Return value

true if the underlying container is empty, false otherwise.

Complexity

Constant.

Example

#include <cassert>
#include <queue>

int main()
{
    std::queue<int> x;
    assert(x.empty());

    x.push(42);
    assert(!x.empty());

    x.pop();
    assert(x.empty());
}

See also

returns the number of elements
(public member function) [edit]
(C++17)
checks whether the container is empty
(function template) [edit]