STD::PMR_MONOTONIC_BUFFER_RESOURCE(3)
π std::pmr::monotonic_buffer_resource π
okay bestie, sit DOWN, because we're about to talk about the manual page for std::pmr::monotonic_buffer_resource from the Library Functions Manual, and honestly? she's iconic. β¨
πΈ NAME πΈ
std::pmr::monotonic_buffer_resource β a memory resource that allocates from a fixed-size buffer. that's it, that's the girl. no cap. π«Ά
β¨ SYNOPSIS β¨
#include <memory_resource>
she inherits std::pmr::memory_resource, like the main character energy she is. π
π Public Member Functions π
monotonic_buffer_resource(const monotonic_buffer_resource &)=deleteβ copy constructor? deleted. we do NOT do copies here. πmonotonic_buffer_resource(memory_resource *__upstream)noexceptβ builds one with just an upstream resource. that's it.monotonic_buffer_resource(size_t __initial_size)noexceptβ builds one with just an initial size.monotonic_buffer_resource(size_t __initial_size, memory_resource *__upstream)noexceptβ size AND upstream, the deluxe combo. πmonotonic_buffer_resource(void *__buffer, size_t __buffer_size)noexceptβ hands her a buffer to start with. cute.monotonic_buffer_resource(void *__buffer, size_t __buffer_size, memory_resource *__upstream)noexceptβ buffer, buffer size, and upstream. the full set, periodt.void * allocate(size_t __bytes, size_t __alignment=_S_max_align)β gimme memory bestie πvoid deallocate(void *__p, size_t __bytes, size_t __alignment=_S_max_align)β (spoiler: this one is lowkey a no-op, more on that below π)bool is_equal(const memory_resource &__other) const noexceptβ are we the same? vibe check. πmonotonic_buffer_resource & operator=(const monotonic_buffer_resource &)=deleteβ assignment? also deleted. no take-backs, no swaps. πvoid release() noexceptβ the big reset. returns all the memory back upstream. π¦memory_resource * upstream_resource() const noexceptβ who's your upstream? spill. π
π§ Protected Member Functions π§
void * do_allocate(size_t __bytes, size_t __alignment)overrideβ the real one doing the allocating.void do_deallocate(void *, size_t, size_t)overrideβ the real one doing the (non-)deallocating.bool do_is_equal(const memory_resource &__other) const noexceptoverrideβ the real one doing the comparing.
π Detailed Description π
A memory resource that allocates from a fixed-size buffer. (yes, saying it again, it's the whole point bestie π )
The main feature of a pmr::monotonic_buffer_resource is that its do_deallocate does nothing. and that's not a bug, that's the flex. it makes it very fast because there is no need to manage a free list, and every allocation simply returns a new block of memory, rather than searching for a suitably-sized free block. no searching. no scrolling. just vibes. β¨
Because deallocating is a no-op, the amount of memory used by the resource only grows until release() (or the destructor) is called to return all memory to upstream. so yeah, she's a hoarder, but like, in a purposeful way. π
A monotonic_buffer_resource can be initialized with a buffer that will be used to satisfy all allocation requests, until the buffer is full. After that a new buffer will be allocated from the upstream resource. and here's the galaxy-brain move: by using a stack buffer and pmr::null_memory_resource() as the upstream you can get a memory resource that only uses the stack and never dynamically allocates. hello?? that's so clean. πβ¨
Since: C++17 β she's been serving since C++17 and she has not slowed down once. periodt. π
π¦ Member Function Documentation π¦
void * std::pmr::monotonic_buffer_resource::do_allocate(size_t __bytes, size_t __alignment) [inline], [override], [protected], [virtual]
Implements std::pmr::memory_resource.
void std::pmr::monotonic_buffer_resource::do_deallocate(void * , size_t , size_t ) [inline], [override], [protected], [virtual]
Implements std::pmr::memory_resource. (remember: she does nothing and we love her for it ππ)
bool std::pmr::monotonic_buffer_resource::do_is_equal(const memory_resource & __other) const [inline], [override], [protected], [virtual], [noexcept]
Implements std::pmr::memory_resource.
π Author π
Generated automatically by Doxygen for libstdc++ from the source code. (yes she was built by a robot and yes she still ate π )
and that's the whole page bestie!! thanks for reading, mwah π«Άπ this was std::pmr::...er_resource(3) from the libstdc++ fam β go forth and allocate monotonically, you gorgeous thing. β¨πΈπ
π¦ 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