std::pmr::m...ce::allocate(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸŽ€ std::pmr::m...ce::allocate(3) πŸŽ€

okay bestie, this is the C++ Standard Libary manual page for the allocation hook on std::pmr::memory_resource. it’s giving β€œlow-level but make it polymorphic.” πŸ’…


✨ NAME ✨

std::pmr::memory_resource::allocate β€” std::pmr::memory_resource::allocate


πŸ¦‹ Synopsis πŸ¦‹

(since C++17) β€” yep, this one’s been hanging out since C++17. 🫢

(until C++20) it looked like this:

void* allocate( std::size_t bytes,
                std::size_t alignment = alignof(std::max_align_t) );

(since C++20) it’s got the [[nodiscard]] glow-up:

[[nodiscard]] void* allocate( std::size_t bytes,
                              std::size_t alignment = alignof(std::max_align_t) );

So what does it do? It allocates storage with a size of at least bytes bytes, aligned to the specified alignment. ✨

Equivalent to return do_allocate(bytes, alignment);.


πŸ’€ Exceptions πŸ’€

It throws an exception if storage of the requested size and alignment cannot be obtained. no cap, if it can’t get the storage, it’s throwing hands 😭

🧚 Defect reports 🧚

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

  • DR: LWG 2843; Applied to: ???; Behavior as published: over-alignment was allowed to be unsupported; Correct behavior: alignment must be honoured.

πŸ‘€ See also πŸ‘€

  • do_allocate allocates memory β€” [virtual] (virtual private member function).

made with love from the source/version at http://cppreference.com, dated 2024.06.10, for the page std::pmr::m...ce::allocate(3) πŸ’–πŸŒΈ

πŸ“¦ where this page comes from