std::pmr::u...:do_allocate(3)
π std::pmr::unsynchronized_pool_resource::do_allocate π
okay so this is a page straight out of the C++ Standard Library manual, and it's all about one very specific little overridden function. bestie, it's giving "niche but iconic" and we're gonna get into it π
β¨ NAME β¨
std::pmr::unsynchronized_pool_resource::do_allocate β yes it's the same name twice, that's just how manpages do, don't @ me π
πΈ Synopsis πΈ
virtual void* do_allocate( std::size_t bytes, std::size_t alignment );
(since C++17) β
It allocates storage, that's the whole vibe. But there's lore:
- If the pool that got selected for a block of size bytes can't satisfy the request from its own internal data structures, it calls
allocate()on the upstream memory resource to go get some memory. like "hey bestie upstream, can you spot me" π«Ά - And if the size you requested is bigger than what the largest pool can even handle? Then memory gets allocated by calling
allocate()on the upstream memory resource too. no pool for you, straight to upstream, periodt π
π¦ Return value π¦
A pointer to allocated storage that's at least bytes bytes in size β and it's aligned to the specified alignment if such alignment is supported π β and aligned to alignof(std::max_align_t) otherwise. either way you're getting a pointer, and it's not messing around.
π₯ Exceptions π₯
Throws nothing unless calling allocate() on the upstream memory resource throws. that's it, that's the whole rule. very "i'm chill until the upstream is not chill" energy π
π See also π
allocateβ allocates memory β¨ (public member function ofstd::pmr::memory_resource)do_allocateβ allocates memory β¨ [virtual] (virtual private member function ofstd::pmr::memory_resource)
(iykyk, they're all just allocate girlies in different outfits π)
π a lil sign-off π
this page came to you courtesy of http://cppreference.com, dated 2024.06.10 β so if anything's changed since then, that's a conversation for future you. mwah, go allocate something responsibly ππ§π
π¦ 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