Namespaces
Variants

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

From cppreference.net

bool empty ( ) const ;

检查底层容器是否为空。等价于: return c . empty ( )

目录

参数

(无)

返回值

若底层容器为空则为 true ,否则为 false

复杂度

常量。

示例

#include <cassert>
#include <stack>
int main()
{
    std::stack<int> stack;
    assert(stack.empty());
    stack.push(42);
    assert(!stack.empty());
    stack.pop();
    assert(stack.empty());
}

参见

返回元素数量
(公开成员函数)
(C++17)
检查容器是否为空
(函数模板)