public static member function
<memory>

std::allocator_traits::max_size

static size_type max_size (allocator_type& alloc);
static size_type max_size (const allocator_type& alloc) noexcept;
Maximum size possible to allocate
Returns the maximum number of elements that could be allocated with allocator alloc.

Still, there is no guarantee that a later call to allocate with that value will succeed.

In the non-specialized definition of allocator_traits, this member function returnsalloc.max_size()if such an expression is well formed. Otherwise, it returnsnumeric_limits<size_type>::max(). A specialization for a specific allocator type may provide a different definition.

参数

alloc
Allocator object
allocator_typeis an alias of allocator_traits's template parameter.

返回值

The number of elements that might be allocated as maximum by a call to allocator_traits::allocate with alloc.
size_typeis a membert type of allocator_traits.

另见