bool empty() const; // C++03
bool empty() const noexcept; // C++11
[[nodiscard]] bool empty() const noexcept; // C++20
bool empty() const noexcept; // C++26
概要
コンテナが空かどうかをテストする。
set コンテナが空(size() が 0)の場合に true を返す。
この関数はコンテナ内のコンテンツを変化させない。コンテンツをクリアするには clear() メンバを使う。
戻り値
コンテナサイズが 0 のときに true, そうでないときに false。
計算量
定数時間。
例
出力
1
0
関連項目
| 名前 | 説明 |
|---|---|
insert |
要素を挿入する |
(constructor) |
コンストラクタ |
参照
- P0600R1
[[nodiscard]]in the Library- C++20で
[[nodiscard]]が付加された
- C++20で
- P2422R1 Remove
nodiscardannotations from the standard library specification- C++26で
[[nodiscard]]指定が削除された
- C++26で