std::pmr::mono...buffer_resource(3cxx)
π std::pmr::monotonic_buffer_resource π
manual page: std::pmr::mono...buffer_resource(3cxx) β yes bestie, that truncated lil header is the actual manual page name. We are in libstdc++ land. π
πΈ NAME πΈ
std::pmr::monotonic_buffer_resource β a memory resource that allocates from a fixed-size buffer. That is the whole vibe: fixed-size buffer, no cap. β¨
β¨ SYNOPSIS β¨
#include <memory_resource>
Inherits std::pmr::memory_resource.
π«Ά Public Member Functions
monotonic_buffer_resource (const monotonic_buffer_resource &)=deleteβ copy constructor? deleted.=delete, not today. π«monotonic_buffer_resource (memory_resource *__upstream) noexceptβ constructor taking an upstreammemory_resource*; it isnoexcept.monotonic_buffer_resource (size_t __initial_size) noexceptβ constructor taking an initial size; it isnoexcept.monotonic_buffer_resource (size_t __initial_size, memory_resource *__upstream) noexceptβ constructor taking an initial size and an upstreammemory_resource*; it isnoexcept.monotonic_buffer_resource (void *__buffer, size_t __buffer_size) noexceptβ constructor taking a buffer and its size; it isnoexcept.monotonic_buffer_resource (void *__buffer, size_t __buffer_size, memory_resource *__upstream) noexceptβ constructor taking a buffer, a buffer size, and an upstreammemory_resource*; it isnoexcept.void * allocate (size_t __bytes, size_t __alignment=_S_max_align)β allocate__byteswith alignment defaulting to_S_max_align. β¨void deallocate (void *__p, size_t __bytes, size_t __alignment=_S_max_align)β deallocate__p; alignment defaults to_S_max_align. Remember:do_deallocateis the no-op queen here. πbool is_equal (const memory_resource &__other) const noexceptβ equality check,noexcept.monotonic_buffer_resource & operator= (const monotonic_buffer_resource &)=deleteβ assignment operator is deleted too; copying is not invited. π«void release () noexceptβ release,noexcept.memory_resource * upstream_resource () const noexceptβ returns the upstreammemory_resource*;noexcept.
π‘οΈ Protected Member Functions
void * do_allocate (size_t __bytes, size_t __alignment) overrideβ protected override hook.void do_deallocate (void *, size_t, size_t) overrideβ protected override hook.bool do_is_equal (const memory_resource &__other) const noexcept overrideβ protected override hook, and it isnoexcept.
π Detailed Description π
A memory resource that allocates from a fixed-size buffer. Okay so the main-character feature of a pmr::monotonic_buffer_resource is that its do_deallocate does nothing. Literally nothing. This 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. 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. The way it just keeps going up? Monotonic behavior, iykyk. π
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. 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. Obsessed with the no-dynamic-allocation fantasy. π«Ά
β³ Since β³
C++17, bestie. That is when this icon entered the chat. π
π§ Member Function Documentation π§
void * std::pmr::monotonic_buffer_resource::do_allocate (size_t __bytes, size_t __alignment) [inline], [override], [protected], [virtual]β implementsstd::pmr::memory_resource.void std::pmr::monotonic_buffer_resource::do_deallocate (void *, size_t, size_t) [inline], [override], [protected], [virtual]β implementsstd::pmr::memory_resource.bool std::pmr::monotonic_buffer_resource::do_is_equal (const memory_resource & __other) const [inline], [override], [protected], [virtual], [noexcept]β implementsstd::pmr::memory_resource.
π Author π
Not a human bestie: generated automatically by Doxygen for libstdc++ from the source code. π€β¨
mwah π β this Doxygen-generated libstdc++ page is std::pmr::mono...buffer_resource(3cxx); its footer line says libstdstd::pmr::mono...buffer_resource(3cxx), and there is no date printed, so I am not making one up. πβ¨
π¦ where this page comes from
- ubuntu noble: libstdc++-14-doc 14-20240412-0ubuntu1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms