GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • cpprefjp - C++日本語リファレンス
  • GitHub Project

This view

  • Original page
  • New address

GeezerVison is showing cpprefjp.github.io — std::unordered_map::max_size - cpprefjp C++日本語リファレンス

  1. リファレンス
  2. unordered_map
  3. unordered_map
  4. max_size

最終更新日時: 2026年09月11日 13時06分31秒 (JST)
Akira Takahashi が更新

履歴 編集

function
<unordered_map>

std::unordered_map::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_map<std::string, int> um;
  decltype(um)::size_type s = um.max_size();

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

出力例

2305843009213693951

バージョン

言語

  • C++11

処理系

  • Clang: 3.0 ✅, 3.1 ✅
  • GCC: 4.4.7 ✅, 4.5.3 ✅, 4.6.3 ✅, 4.7.0 ✅
  • Visual C++: ?

備考

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

関連項目

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

参照

  • P3372R3 constexpr containers and adaptors
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.