std::pmr::null_memory_resource - cppreference.com (original) (raw)

Returns a pointer to a memory_resource that doesn't perform any allocation.

[edit] Return value

Returns a pointer p to a static storage duration object of a type derived from std::pmr::memory_resource, with the following properties:

The same value is returned every time this function is called.

[edit] Example

The program demos the main usage of null_memory_resource: ensure that a memory pool which requires memory allocated on the stack will NOT allocate memory on the heap if it needs more memory.

Possible output:

size: 50... size: 100... size: 150... std::bad_alloc size: 183