A resource using a caller-owned buffer, with a trivial deallocate.
Defined in header
class static_resource : public memory_resource
Copy assignment (deleted)
Release all allocated memory.
Copy constructor (deleted)
This memory resource is a special-purpose resource that releases allocated
memory only when the resource is destroyed (or when
release is called). It has a trivial
deallocate function; that is, the metafunction
The resource is constructed from a caller-owned buffer from which subsequent
calls to allocate are apportioned. When a memory request cannot be satisfied
from the free bytes remaining in the buffer, the allocation request fails
with the exception
This parses a JSON into a value which uses a local stack buffer, then prints the result.
unsigned char buf[ 4000 ]; static_resource mr( buf ); // Parse the string, using our memory resource value const jv = parse( "[1,2,3]", &mr ); // Print the JSON std::cout << jv;
Members of the same instance may not be called concurrently.