- 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
- Clang: 3.0
- GCC, C++11 mode: 4.7.3
- ICC: ??
- Visual C++: 2012, 2013