std::pmr::m...do_allocate(3)

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

πŸ’– NAME πŸ’–

Okay so bestie, this page is std::pmr::memory_resource::do_allocate β€” and yes, the NAME line is basically <pink>std::pmr::memory_resource::do_allocate</pink> dash <pink>std::pmr::memory_resource::do_allocate</pink> again. Iconic redundancy, no notes πŸ’….

The manual name folded in near the top is C++ Standard Libary (spelling exactly like the header, no cap 😭🫢). Page vibes: std::pmr::memory_resource::do_allocate(3).

✨ Synopsis ✨

The signature is exactly this, bestie:

virtual void* do_allocate( std::size_t bytes, std::size_t alignment )

It's marked (since C++17), and it ends with = 0; β€” yes, that = 0; is literally part of the synopsis, not a typo 🌸.

What it does: allocates storage with a size of at least bytes bytes, aligned to the specified alignment.

And the rule that is not playing around: alignment shall be a power of two. Periodt πŸ”₯.

😭 Exceptions 😭

Throws an exception if storage of the requested size and alignment cannot be obtained. That's the exception lore, and it's giving "handle it or catch feelings" πŸ’€.

🩹 Defect reports 🩹

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

  • DR: LWG 2843 β€” Applied to: C++17 β€” Behavior as published: contradictory β€” Correct behavior: handling of unsupported alignment throws an exception.

πŸ‘‘ See also πŸ‘‘

  • allocate β€” allocates memory (public member function)

πŸ’– That's the page, bestie. Source/version: http://cppreference.com Β· date: 2024.06.10 β€” now go forth and allocate with main-character energy πŸ’…βœ¨

πŸ“¦ where this page comes from