std::experi...do_allocate(3)

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

πŸ’… std::experimental::pmr::monotonic_buffer_resource::do_allocate

okay so real quick β€” this is a page from the C++ Standard Library manual, and we're talking about the std::experimental::pmr::monotonic_buffer_resource::do_allocate function. yes the name is a whole paragraph, we don't talk about it πŸ’€


✨ NAME ✨

std::experimental::pmr::monotonic_buffer_resource::do_allocate β€” like, literally the exact same thing again bestie, std::experimental::pmr::monotonic_buffer_resource::do_allocate. the manual is just being extra πŸŽ€


πŸ¦‹ Synopsis

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

library fundamentals TS energy ✨


🌸 DESCRIPTION 🌸

It allocates storage. that's the whole vibe.

So here's the tea β˜• β€” if the current buffer has enough unused space to fit a block with the specified size and alignment, then it allocates the return block right out of the current buffer. easy, no drama, ate πŸ’…

Otherwise? it allocates a new buffer by calling upstream_resource()->allocate(n, m), where n is not less than the greater of bytes and the next buffer size, and m is not less than alignment. then it sets the new buffer as the current buffer, increases the next buffer size by an implementation-defined growth factor (which is not necessarily integral β€” yes that's a real caveat, don't come for me πŸ™ˆ), and then allocates the return block from the newly allocated buffer. main character energy fr fr πŸ‘‘


πŸ’– Return value

A pointer to allocated storage of at least bytes bytes in size, aligned to the specified alignment if such alignment is supported, and to alignof(std::max_align_t) otherwise. slay 🫢


πŸ”₯ Exceptions

Throws nothing unless calling allocate() on the upstream memory resource throws. that's it, that's the whole rule 🧚


⭐ See also

  • allocate β€” allocates memory (public member function of std::experimental::pmr::memory_resource)
  • do_allocate [virtual] β€” allocates memory (virtual protected member function of std::experimental::pmr::memory_resource)

πŸŽ€ Category:

  • Noindexed pages

ngl the [virtual] tag on that second one is doing a lot of heavy lifting β€” it's a virtual protected member function, so mind your access, bestie 😭

okay that's the whole page, you're welcome πŸ’œ this one came straight from http://cppreference.com, dated 2024.06.10, from the std::experi...do_allocate(3) page β€” mwah, go allocate something responsibly ✨🌸

πŸ“¦ where this page comes from