bit::memory
Public Types | Public Member Functions | List of all members
bit::memory::new_allocator Class Reference

This stateless allocator performs all of its allocation calls using raw calls to 'new', and frees memory with 'delete'. More...

#include <new_allocator.hpp>

Public Types

using default_alignment = std::integral_constant< std::size_t, alignof(std::max_align_t)>
 

Public Member Functions

 new_allocator ()=default
 Default-constructs a new_allocator.
 
 new_allocator (new_allocator &&other) noexcept=default
 Move-constructs a new_allocator from another allocator. More...
 
 new_allocator (const new_allocator &other) noexcept=default
 Copy-constructs a new_allocator from another allocator. More...
 
new_allocatoroperator= (new_allocator &&other) noexcept=default
 Move-assigns a new_allocator from another allocator. More...
 
new_allocatoroperator= (const new_allocator &other) noexcept=default
 Copy-assigns a new_allocator from another allocator. More...
 
owner< void * > try_allocate (std::size_t size, std::size_t align) noexcept
 Attempts to allocate memory of size size, returning nullptr on failure. More...
 
void deallocate (owner< void *> p, std::size_t size)
 Deallocates a pointer p with the allocation size of size. More...
 
allocator_info info () const noexcept
 Gets the info about this allocator. More...
 

Detailed Description

This stateless allocator performs all of its allocation calls using raw calls to 'new', and frees memory with 'delete'.

Any alignment requests are ignored

Satisfies
Allocator
Satisfies
Stateless

Definition at line 59 of file new_allocator.hpp.

Constructor & Destructor Documentation

◆ new_allocator() [1/2]

bit::memory::new_allocator::new_allocator ( new_allocator &&  other)
defaultnoexcept

Move-constructs a new_allocator from another allocator.

Parameters
otherthe other new_allocator to move

◆ new_allocator() [2/2]

bit::memory::new_allocator::new_allocator ( const new_allocator other)
defaultnoexcept

Copy-constructs a new_allocator from another allocator.

Parameters
otherthe other new_allocator to copy

Member Function Documentation

◆ deallocate()

void bit::memory::new_allocator::deallocate ( owner< void *>  p,
std::size_t  size 
)

Deallocates a pointer p with the allocation size of size.

Parameters
pthe pointer to deallocate
sizethe size to deallocate

◆ info()

allocator_info bit::memory::new_allocator::info ( ) const
noexcept

Gets the info about this allocator.

This defaults to 'malloc_allocator'. Use a named_malloc_allocator to override this

Returns
the info for this allocator

◆ operator=() [1/2]

new_allocator& bit::memory::new_allocator::operator= ( new_allocator &&  other)
defaultnoexcept

Move-assigns a new_allocator from another allocator.

Parameters
otherthe other new_allocator to move
Returns
reference to (*this)

◆ operator=() [2/2]

new_allocator& bit::memory::new_allocator::operator= ( const new_allocator other)
defaultnoexcept

Copy-assigns a new_allocator from another allocator.

Parameters
otherthe other new_allocator to copy
Returns
reference to (*this)

◆ try_allocate()

owner<void*> bit::memory::new_allocator::try_allocate ( std::size_t  size,
std::size_t  align 
)
noexcept

Attempts to allocate memory of size size, returning nullptr on failure.

The alignment is ignored for calls to this allocator. The alignment is always guaranteed to be at least alignof(std::max_align_t)

Parameters
sizethe size of this allocation
alignthe requested alignment (ignored)
Returns
the allocated pointer

The documentation for this class was generated from the following file: