std::allocation_result

From cppreference.com
< cpp‎ | memory
 
 
Utilities library
General utilities
Date and time
Function objects
Formatting library (C++20)
(C++11)
Relational operators (deprecated in C++20)
Integer comparison functions
(C++20)(C++20)(C++20)   
(C++20)
Swap and type operations
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
Common vocabulary types
(C++11)
(C++17)
(C++17)
(C++17)
(C++11)
(C++17)
(C++23)
Elementary string conversions
(C++17)
(C++17)
 
Dynamic memory management
Smart pointers
(C++11)
(C++11)
(C++11)
(until C++17)
(C++11)
(C++23)
Allocators
allocation_result
(C++23)
Memory resources
Uninitialized storage
Uninitialized memory algorithms
Constrained uninitialized memory algorithms
Garbage collection support
(C++11)(until C++23)
(C++11)(until C++23)
(C++11)(until C++23)
(C++11)(until C++23)
(C++11)(until C++23)
(C++11)(until C++23)
Miscellaneous
(C++20)
(C++11)
(C++11)
 
Defined in header <memory>
template< class Pointer >

struct allocation_result {
    Pointer ptr;
    std::size_t count;

};
(since C++23)

allocation_result specializations are return types of the allocate_at_least member function of appropriate Allocator types (e.g. std::allocator::allocate_at_least) and std::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

Member objects

ptr
(C++23)
typically used for the address of the first element in the storage allocated by allocate_at_least
(public member object)
count
(C++23)
typically used for the actual number of elements in the storage allocated by allocate_at_least
(public member object)

Notes

Feature-test macro: __cpp_lib_allocate_at_least

Example

See also

allocates uninitialized storage at least as large as requested size
(public member function of std::allocator<T>)
allocates storage at least as large as the requested size via an allocator
(function template)