Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/memory/allocation result"

From cppreference.com
< cpp‎ | memory
(P2652R2 - allocator_at_least becomes a member function)
m
Line 5: Line 5:
 
struct allocation_result {
 
struct allocation_result {
 
     Pointer ptr;
 
     Pointer ptr;
     class SizeType count;
+
     SizeType count;
 
};
 
};
 
}}
 
}}

Revision as of 17:21, 12 February 2023

 
 
Utilities library
General utilities
Relational operators (deprecated in C++20)
 
Dynamic memory management
Uninitialized memory algorithms
Constrained uninitialized memory algorithms
Allocators
allocation_result
(C++23)
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)



 
Defined in header <memory>
template< class Pointer, class SizeType >

struct allocation_result {
    Pointer ptr;
    SizeType count;

};
(since C++23)

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.

Contents

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

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

Pointer and SizeType are a pointer to an object type and std::size_t by default.

Feature-test macro Value Std Feature
__cpp_lib_allocate_at_least 202106L (C++23)

Example

See also

allocates uninitialized storage at least as large as requested size
(public member function of std::allocator<T>) [edit]