Skip to content

Latest commit

 

History

History
61 lines (47 loc) · 1.51 KB

File metadata and controls

61 lines (47 loc) · 1.51 KB

max_size

  • memory[meta header]
  • std[meta namespace]
  • allocator_traits[meta class]
  • function[meta id-type]
  • cpp11[meta cpp]
static size_type max_size(Alloc& a);                // C++11
static size_type max_size(const Alloc& a) noexcept; // C++14

概要

一度に確保可能なメモリの最大サイズを取得する。

戻り値

a.max_size()という式が有効ならその戻り値を返し、そうでなければデフォルト実装として以下を返す:

std::numeric_limits<size_type>::max() / sizeof(value_type)
  • max()[link /reference/limits/numeric_limits/max.md]

#include <iostream>
#include <memory>

int main()
{
  std::allocator<int> alloc;
  using traits = std::allocator_traits<decltype(alloc)>;

  std::cout << traits::max_size(alloc) << std::endl;
}
  • max_size[color ff0000]
  • std::allocator[link /reference/memory/allocator.md]

出力例

4611686018427387903

バージョン

言語

  • C++11

処理系

参照