size_type capacity() const noexcept; // (1) C++26
概要
要素ブロックを追加確保せずに保持できる要素数を取得する。
戻り値
要素ブロックの追加確保を必要とせずに*thisが保持できる総要素数
例外
投げない
計算量
定数時間
例
#include <hive>
#include <print>
int main()
{
std::hive<int> h;
// 100要素分の領域を予約する
h.reserve(100);
// 予約した領域を確認する
std::println("size = {}", h.size());
std::println("capacity >= 100 : {}", h.capacity() >= 100);
}
出力
size = 0
capacity >= 100 : true
バージョン
言語
- C++26
処理系
- Clang: 22 ❌
- GCC: 16.1 ❌
- Visual C++: 2026 Update 2 ❌
関連項目
参照
- P0447R28 Introduction of
std::hiveto the standard library- C++26で
hiveが追加された
- C++26で