Difference between revisions of "cpp/memory/allocation result"
From cppreference.com
m (→See also: +) |
m (~) |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{cpp/title|allocation_result}} | {{cpp/title|allocation_result}} | ||
{{cpp/memory/navbar}} | {{cpp/memory/navbar}} | ||
− | {{ddcl | header=memory | since=c++23 | | + | {{ddcl|header=memory|since=c++23|1= |
− | template< class Pointer, class SizeType > | + | template< class Pointer, class SizeType = std::size_t > |
− | struct allocation_result | + | struct allocation_result; |
− | + | ||
− | + | ||
− | + | ||
}} | }} | ||
− | {{tt|allocation_result}} specializations are returned from the {{tt|allocate_at_least}} member function of appropriate {{named req|Allocator}} types (e.g. {{ltt|cpp/memory/allocator/allocate_at_least|std::allocator::allocate_at_least}}) and {{ltt|cpp/memory/ | + | {{tt|allocation_result}} specializations are returned from the {{tt|allocate_at_least}} member function of appropriate {{named req|Allocator}} types (e.g. {{ltt|cpp/memory/allocator/allocate_at_least|std::allocator::allocate_at_least}}) and {{ltt|cpp/memory/allocator_traits/allocate_at_least|std::allocator_traits::allocate_at_least}}. |
− | Every specialization of {{tt|allocation_result}} has no base classes or declared members other than {{tt|ptr}} and {{tt|count}}, thus it is suitable for | + | Every specialization of {{tt|allocation_result}} has no base classes or declared members other than {{tt|ptr}} and {{tt|count}}, thus it is suitable for {{lt|cpp/language/aggregate initialization}} and {{lt|cpp/language/structured binding}}. |
===Template parameters=== | ===Template parameters=== | ||
{{par begin}} | {{par begin}} | ||
− | {{par | Pointer | typically {{c|std::allocator_traits<Alloc>::pointer}}, where {{tt|Alloc}} is an {{named req|Allocator}} type}} | + | {{par|Pointer|typically {{c|std::allocator_traits<Alloc>::pointer}}, where {{tt|Alloc}} is an {{named req|Allocator}} type}} |
− | {{par | SizeType | typically {{c|std::allocator_traits<Alloc>::size_type}}, where {{tt|Alloc}} is an {{named req|Allocator}} type}} | + | {{par|SizeType|typically {{c|std::allocator_traits<Alloc>::size_type}}, where {{tt|Alloc}} is an {{named req|Allocator}} type}} |
{{par end}} | {{par end}} | ||
− | === | + | ===Data members=== |
{{dsc begin}} | {{dsc begin}} | ||
− | {{dsc mem obj | ptr | nolink=true | | + | {{dsc hitem|Member name|Definition}} |
− | {{dsc mem obj | count | nolink=true | | + | {{dsc mem obj|ptr|nolink=true|a pointer of type {{tt|Pointer}} which is typically used for the address of the first element in the storage allocated by {{tt|allocate_at_least}}}} |
+ | {{dsc mem obj|count|nolink=true|a value of type {{tt|SizeType}} which is typically used for the actual number of elements in the storage allocated by {{tt|allocate_at_least}}}} | ||
{{dsc end}} | {{dsc end}} | ||
Line 28: | Line 26: | ||
{{tt|Pointer}} and {{tt|SizeType}} are a pointer to an object type and {{c|std::make_unsigned_t<std::ptrdiff_t>}} (which is almost always same as {{lc|std::size_t}}) by default. | {{tt|Pointer}} and {{tt|SizeType}} are a pointer to an object type and {{c|std::make_unsigned_t<std::ptrdiff_t>}} (which is almost always same as {{lc|std::size_t}}) by default. | ||
− | {{feature test macro|__cpp_lib_allocate_at_least|std=C++23|value= | + | {{feature test macro|__cpp_lib_allocate_at_least|std=C++23|value=202302L|Size-feedback in the Allocator interface}} |
===Example=== | ===Example=== | ||
Line 35: | Line 33: | ||
===See also=== | ===See also=== | ||
{{dsc begin}} | {{dsc begin}} | ||
− | {{dsc inc | cpp/memory/allocator/dsc allocate_at_least}} | + | {{dsc inc|cpp/memory/allocator/dsc allocate_at_least}} |
− | {{dsc inc | cpp/memory/allocator_traits/dsc allocate_at_least}} | + | {{dsc inc|cpp/memory/allocator_traits/dsc allocate_at_least}} |
{{dsc end}} | {{dsc end}} | ||
{{langlinks|es|ja|ru|zh}} | {{langlinks|es|ja|ru|zh}} |
Latest revision as of 01:53, 13 April 2024
Defined in header <memory>
|
||
template< class Pointer, class SizeType = std::size_t > struct allocation_result; |
(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 |
[edit] 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
|
[edit] Data members
Member name | Definition |
ptr |
a pointer of type Pointer which is typically used for the address of the first element in the storage allocated by allocate_at_least (public member object) |
count |
a value of type SizeType which is typically used for the actual number of elements in the storage allocated by allocate_at_least (public member object) |
[edit] 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 macro | Value | Std | Feature |
---|---|---|---|
__cpp_lib_allocate_at_least |
202302L | (C++23) | Size-feedback in the Allocator interface |
[edit] Example
This section is incomplete Reason: no example |
[edit] See also
(C++23) |
allocates uninitialized storage at least as large as requested size (public member function of std::allocator<T> )
|
[static] (C++23) |
allocates storage at least as large as the requested size via an allocator (public static member function of std::allocator_traits<Alloc> )
|