std::pmr::p...locate_bytes(3)
π NAME π
This is the std::pmr::p...locate_bytes(3) page from the C++ Standard Libary manual β yes, that's the header spelling, we're keeping the detail and moving on π
. The name is std::pmr::polymorphic_allocator::allocate_bytes β std::pmr::polymorphic_allocator::allocate_bytes. Yep, the original repeats it, and we're not skipping a single crumb. Periodt.
β¨ Synopsis β¨
Okay so this one is tagged (since C++20), bestie. Here's the signature β the version tag is literally just a tag, not an argument:
[[nodiscard]] void* allocate_bytes( std::size_t nbytes,
std::size_t alignment =
alignof(std::max_align_t) );
Allocates nbytes bytes of storage at specified alignment alignment using the underlying memory resource. It is equivalent to literally doing:
return resource()->allocate(nbytes, alignment);
π Parameters π
nbytesβ the number of bytes to allocate.alignmentβ the alignment to use.
π«Ά Return value π«Ά
A pointer to the allocated storage. That's the whole return value, no cap π.
π Notes π
This function was introduced for use with the fully-specialized allocator std::pmr::polymorphic_allocator<>, but it may be useful in any specialization. So yes, it can pop off outside the fully-specialized case too.
The return type is void* (rather than, e.g., std::byte*) to support conversion to an arbitrary pointer type U* by static_cast<U*>. That's the reason, bestie, and it's lowkey iconic.
π Exceptions π
May throw any exceptions thrown by the call to resource()->allocate. So if the underlying resource is being dramatic, this function is matching energy π.
π See also π
allocate_objectβ allocates raw memory suitable for an object or an array(C++20)(public member function)new_objectβ allocates and constructs an object(C++20)(public member function)allocateβ allocate memory (public member function)allocateβ allocates uninitialized storage using the allocator[static](public static member function ofstd::allocator_traits<Alloc>)allocateβ allocates memory (public member function ofstd::pmr::memory_resource)
Source: http://cppreference.com Β· version/date: 2024.06.10 Β· manual: std::pmr::p...locate_bytes(3). Bye bestie, go allocate something iconic πβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms