std::pmr::p...cate_object(3)
π NAME π
okay bestie, this is the C++ Standard Libary manual, section (3), and the function is std::pmr::polymorphic_allocator::allocate_object β the short description is literally the same thing: std::pmr::polymorphic_allocator::allocate_object. iconic, honestly π
β¨ Synopsis β¨
template< class U > (since C++20)
[[nodiscard]] U* allocate_object( std::size_t n = 1 );
Allocates storage for n objects of type U using the underlying memory resource.
If std::numeric_limits<std::size_t>::max() / sizeof(U) < n, it throws std::bad_array_new_length; otherwise itβs equivalent to return static_cast<U*>(allocate_bytes(n * sizeof(U), alignof(U)));.
π Parameters π
nβ the number of objects to allocate storage for. Thatβs the whole parameter, bestie; sheβs simple and she knows it π«Ά
πΈ Return value πΈ
A pointer to the allocated storage. slay β¨
π¦ Notes π¦
This function was introduced for use with the fully-specialized allocator std::pmr::polymorphic_allocator<>, but it may be useful in any specialization as a shortcut to avoid having to rebind from std::pmr::polymorphic_allocator<T> to std::pmr::polymorphic_allocator<U>.
Since U is not deduced, it must be provided as a template argument when calling this function. no cap, you gotta say it with your chest π
π Exceptions π
Throws std::bad_array_new_length if n > std::numeric_limits<std::size_t>::max() / sizeof(U); may also be any exceptions thrown by the call to resource()->allocate.
bestie, read that condition carefully β this is the βtoo much math, too much sizeβ situation, and she WILL throw π
π See also π
allocate_bytesβ allocate raw aligned memory from the underlying resource (C++20) (public member function)new_objectβ allocates and constructs an object (C++20) (public member function)allocateβ allocate memory (public member function)allocate[static]β allocates uninitialized storage using the allocator (public static member function ofstd::allocator_traits<Alloc>)allocateβ allocates memory (public member function ofstd::pmr::memory_resource)
and thatβs the whole page, bestie π«Ά source/version: http://cppreference.com Β· date: 2024.06.10 Β· footer tag: std::pmr::p...cate_object(3) β mwah πβ¨
π¦ 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