STD::PMR_MEMORY_RESOURCE(3)

πŸ’– std::pmr::memory_resource β€” the whole vibe πŸ’–

okay bestie, welcome to the libstdc++ Library Functions Manual, section 3 (that's the "library functions" shelf of the man page library, iykyk). today we're talking about std::pmr::memory_resource, and honestly? it's giving allocator royalty. πŸ‘‘


✨ NAME ✨

std::pmr::memory_resource β€” Class memory_resource.

like, that's it, that's the class. iconic behavior fr. πŸ’…


🌸 SYNOPSIS 🌸

#include <memory_resource>
πŸ’‘ plot twist: this class gets inherited by std::pmr::monotonic_buffer_resource and std::pmr::unsynchronized_pool_resource. so it's lowkey the mom friend of the polymorphic memory world. 🫢

πŸŽ€ Public Member Functions πŸŽ€

memory_resource (const memory_resource &)=default
void * allocate (size_t __bytes, size_t __alignment=_S_max_align)
void deallocate (void *__p, size_t __bytes, size_t
    __alignment=_S_max_align)
bool is_equal (const memory_resource &__other) const noexcept
memory_resource & operator= (const memory_resource &)=default

lemme break that down for you, one by one:

  • memory_resource (const memory_resource &)=default β€” the copy constructor, and it's =default so the compiler handles it, no drama, no custom code. 😌
  • void * allocate (size_t __bytes, size_t __alignment=_S_max_align) β€” hand it some __bytes and a __alignment (which defaults to _S_max_align, she has a default, she's thoughtful like that) and it gives you back a void *. ✨
  • void deallocate (void *__p, size_t __bytes, size_t __alignment=_S_max_align) β€” the reverse: give back the pointer __p, the __bytes, and the __alignment (again defaulting to _S_max_align). what goes around comes around bestie. πŸ¦‹
  • bool is_equal (const memory_resource &__other) const noexcept β€” compares you to __other and returns a bool. and yes she's const and noexcept, because she's that girl. πŸ’…
  • memory_resource & operator= (const memory_resource &)=default β€” the copy assignment operator, also =default. compiler's got it, we don't lift a finger. πŸ™ˆ

πŸ‘‘ Detailed Description πŸ‘‘

Class memory_resource.

that's the whole description, she said "less is more". πŸ’œ

⭐ Since ⭐

C++17

so like, if you're on anything older, bestie, it's not happening. sorry not sorry. 😭


🌈 Author 🌈

Generated automatically by Doxygen for libstdc++ from the source code.

ngl it wasn't a human, it was a doc generator, and it ate. no cap. πŸ”₯


and that's the whole page!! footer said it's libstdc++, and it's page std::pmr::...ry_resource(3) β€” yes the title is truncated with dots, she's mysterious like that. 🧚 mwah, go allocate responsibly. πŸ’–πŸŽ€πŸŒΈ

πŸ“¦ where this page comes from
  • arch rolling: gcc 16.2.1+r23+gd564253eb6c8-1 Β· GPL-3.0-or-later WITH GCC-exception-3.1 AND GFDL-1.3-or-later
  • fedora 44: libstdc++-docs 16.0.1-0.10.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • fedora 44: libstdc++-docs 16.2.1-2.fc44
  • fedora 44: libstdc++-docs 16.2.1-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms