[mem.res.public]

# 20 Memory management library [[mem]](./#mem)

## 20.5 Memory resources [[mem.res]](mem.res#public)

### 20.5.2 Class memory_resource [[mem.res.class]](mem.res.class#mem.res.public)

#### 20.5.2.2 Public member functions [mem.res.public]

[ð](#lib:memory_resource,destructor)

`~memory_resource();
`

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L7524)

*Effects*: Destroys this memory_resource[.](#1.sentence-1)

[ð](#lib:allocate,memory_resource)

`void* allocate(size_t bytes, size_t alignment = max_align);
`

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L7535)

*Effects*: Allocates storage by calling do_allocate(bytes, alignment) and
implicitly creates objects within the allocated region of storage[.](#2.sentence-1)

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L7540)

*Returns*: A pointer to a suitable created object ([[intro.object]](intro.object "6.8.2 Object model"))
in the allocated region of storage[.](#3.sentence-1)

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L7545)

*Throws*: What and when the call to do_allocate throws[.](#4.sentence-1)

[ð](#lib:deallocate,memory_resource)

`void deallocate(void* p, size_t bytes, size_t alignment = max_align);
`

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L7556)

*Effects*: Equivalent to do_deallocate(p, bytes, alignment)[.](#5.sentence-1)

[ð](#lib:is_equal,memory_resource)

`bool is_equal(const memory_resource& other) const noexcept;
`

[6](#6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L7567)

*Effects*: Equivalent to: return do_is_equal(other);
