std::list<T,Allocator>::empty
提供: cppreference.com
bool empty() const; |
(C++11未満) | |
bool empty() const noexcept; |
(C++11以上) (C++20未満) |
|
[[nodiscard]] bool empty() const noexcept; |
(C++20以上) | |
コンテナの持っている要素が無い、つまり begin() == end() かどうかを調べます。
目次 |
[編集] 引数
(なし)
[編集] 戻り値
コンテナが空であれば true、そうでなければ false。
[編集] 計算量
一定。
[編集] 例
以下のコードは empty
を使用して std::list<int> が空かどうか調べます。
Run this code
出力:
Initially, numbers.empty(): 1 After adding elements, numbers.empty(): 0
関連項目
要素数を返します (パブリックメンバ関数) |