bit::memory
|
An allocator that only ever serves nullptr. More...
#include <null_allocator.hpp>
Public Types | |
using | default_alignment = std::integral_constant< std::size_t, 1 > |
Public Member Functions | |
null_allocator ()=default | |
Default-constructs a null_allocator. | |
null_allocator (null_allocator &&other) noexcept=default | |
Move-constructs a null_allocator from another allocator. More... | |
null_allocator (const null_allocator &other) noexcept=default | |
Copy-constructs a null_allocator from another allocator. More... | |
null_allocator & | operator= (null_allocator &&other) noexcept=default |
Move-assigns a null_allocator from another allocator. More... | |
null_allocator & | operator= (const null_allocator &other) noexcept=default |
Copy-assigns a null_allocator from another allocator. More... | |
owner< void * > | try_allocate (std::size_t size, std::size_t align, std::size_t offset=0) noexcept |
Allocates a null pointer. More... | |
void | deallocate (owner< void *> p, std::size_t n) noexcept |
Deallocates a pointer previously allocated with a call to allocate. More... | |
bool | owns (const void *p) const noexcept |
Checks if the pointer p is contained in the null_allocator. More... | |
bool | owns (std::nullptr_t) const noexcept |
Checks if nullptr is part of this allocator. More... | |
allocator_info | info () const noexcept |
Gets the info about this allocator. More... | |
An allocator that only ever serves nullptr.
As is expected, the size and alignment of the allocation will always be ignored, since this only returns nullptr.
Invoking null_allocator::deallocate
on a pointer has no effect, but is considered bad-practice, since this allocator could never produce a valid allocation.
Definition at line 61 of file null_allocator.hpp.
|
defaultnoexcept |
Move-constructs a null_allocator from another allocator.
other | the other null_allocator to move |
|
defaultnoexcept |
Copy-constructs a null_allocator from another allocator.
other | the other null_allocator to copy |
|
noexcept |
Deallocates a pointer previously allocated with a call to allocate.
p | the pointer to deallocate |
n | the number of entries previously allocated |
|
noexcept |
Gets the info about this allocator.
This defaults to 'null_allocator'. Use a named_null_allocator to override this
|
defaultnoexcept |
Move-assigns a null_allocator from another allocator.
other | the other null_allocator to move |
(*this)
|
defaultnoexcept |
Copy-assigns a null_allocator from another allocator.
other | the other null_allocator to copy |
(*this)
|
noexcept |
Checks if the pointer p
is contained in the null_allocator.
p | the pointer to check |
true
if p
is nullptr
|
noexcept |
Checks if nullptr is part of this allocator.
|
noexcept |
Allocates a null pointer.
size | the size of the allocation |
align | the alignment of the allocation |