Skip to main content

std::allocation_result

Defined inmemory
Since C++23
template< class Pointer, class SizeType = std::size_t >
struct allocation_result {
Pointer ptr;
SizeType count;
};

allocation_result specializations are returned from the allocate_at_least member function of appropriate Allocator types (e.g. std::allocator::allocate_at_least) and std::allocator_traits::allocate_at_least.

Every specialization of allocation_result has no base classes or declared members other than ptr and count, thus it is suitable for aggregate initialization and structured binding.

Template parameters

Pointer - typically std::allocator_traits<Alloc>::pointer, where Alloc is an Allocator type
SizeType - typically std::allocator_traits<Alloc>::size_type, where Alloc is an Allocator type

Member objects

pubptr(C++23)typically used for the address of the first element in the storage allocated by allocate_at_least
pubcount(C++23)typically used for the actual number of elements in the storage allocated by allocate_at_least

Notes

Pointer and SizeType are a pointer to an object type and std::make_unsigned_t<std::ptrdiff_t> (which is almost always same as std::size_t) by default.

Feature-test macroValueStd
__cpp_lib_allocate_at_least202302L(C++23)

Example

This section is incomplete

std::allocation_result

Defined inmemory
Since C++23
template< class Pointer, class SizeType = std::size_t >
struct allocation_result {
Pointer ptr;
SizeType count;
};

allocation_result specializations are returned from the allocate_at_least member function of appropriate Allocator types (e.g. std::allocator::allocate_at_least) and std::allocator_traits::allocate_at_least.

Every specialization of allocation_result has no base classes or declared members other than ptr and count, thus it is suitable for aggregate initialization and structured binding.

Template parameters

Pointer - typically std::allocator_traits<Alloc>::pointer, where Alloc is an Allocator type
SizeType - typically std::allocator_traits<Alloc>::size_type, where Alloc is an Allocator type

Member objects

pubptr(C++23)typically used for the address of the first element in the storage allocated by allocate_at_least
pubcount(C++23)typically used for the actual number of elements in the storage allocated by allocate_at_least

Notes

Pointer and SizeType are a pointer to an object type and std::make_unsigned_t<std::ptrdiff_t> (which is almost always same as std::size_t) by default.

Feature-test macroValueStd
__cpp_lib_allocate_at_least202302L(C++23)

Example

This section is incomplete