最終更新日時(UTC): 2026年02月17日 14時22分33秒
Akira Takahashi が更新

履歴 編集

function
<unordered_map>

std::unordered_multimap::max_size(C++11)

size_type max_size() const noexcept;           // (1) C++11
constexpr size_type max_size() const noexcept; // (1) C++26

概要

格納可能な最大の要素数を取得する。

戻り値

このコンテナに格納可能な最大の要素数

例外

投げない。

計算量

定数

#include <iostream>
#include <string>
#include <unordered_map>

int main()
{
  std::unordered_multimap<std::string, int> um;
  decltype(um)::size_type s = um.max_size();

  std::cout << s << std::endl;
}

出力例

576460752303423487

バージョン

言語

  • C++11

処理系

備考

libstdc++ では、コンテナのアロケータ allocator_type にメンバ関数 max_size が無いとコンパイル時エラーが発生する。 (allocator_type::max_size()std::allocator_traits::max_size 経由ではなく直接使用しているため。)

関連項目

名前 説明
empty コンテナが空かどうかを判定
size 要素数の取得

参照

Morty Proxy This is a proxified and sanitized view of the page, visit original site.