最終更新日時(UTC):
が更新

履歴 編集

function
<vector>

std::vector::max_size

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

概要

コンテナに格納可能な最大数を取得する。

戻り値

コンテナに格納可能な最大数

例外

投げない

計算量

定数時間

#include <iostream>
#include <vector>

int main()
{
  std::vector<int> v;
  std::size_t s = v.max_size();

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

出力例

4611686018427387903

参照