bit::memory
Public Types | Public Member Functions | List of all members
bit::memory::allocator_deleter< T, AllocatorStorage > Class Template Reference

A deleter for custom allocators in the library. More...

#include <allocator_deleter.hpp>

Inheritance diagram for bit::memory::allocator_deleter< T, AllocatorStorage >:
bit::memory::ebo_storage< AllocatorStorage >

Public Types

using void_pointer = typename alloc_traits::pointer
 
using pointer = typename pointer_traits::template rebind< T >
 
using size_type = typename alloc_traits::size_type
 
using difference_type = typename alloc_traits::difference_type
 

Public Member Functions

 allocator_deleter (AllocatorStorage storage)
 Constructs an allocator_deleter that uses the referenced allocator for deletion. More...
 
 allocator_deleter (allocator_deleter &&other) noexcept=default
 Move-constructs an allocator_deleter from an existing one. More...
 
 allocator_deleter (const allocator_deleter &other) noexcept=default
 Copy-constructs the allocator_deleter from an existing one. More...
 
allocator_deleteroperator= (allocator_deleter &&other) noexcept=default
 Move-assigns an allocator_deleter from an existing one. More...
 
allocator_deleteroperator= (const allocator_deleter &other) noexcept=default
 Copy-assigns an allocator_deleter from an existing one. More...
 
void operator() (pointer p)
 Deletes the underlying pointer p. More...
 

Detailed Description

template<typename T, typename AllocatorStorage>
class bit::memory::allocator_deleter< T, AllocatorStorage >

A deleter for custom allocators in the library.

For any stateless allocator, this leverages EBO to avoid the need for storage.

Note
Unlike std::default_delete, this deleter does not have a converting constructor that allows for 'allocator_deleter<Derived,...> -> allocator_deleter<Base,...>' since the size of the deallocation is computed based on the size of T. To support polymorphism with deleters, see polymorphic_allocator_deleter which always incurs the size cost.
Satisfies
Deleter
Template Parameters
Tthe type being deallocated
Allocatorthe allocator to deallocate with

Definition at line 73 of file allocator_deleter.hpp.

Constructor & Destructor Documentation

◆ allocator_deleter() [1/3]

template<typename T , typename AllocatorStorage >
bit::memory::allocator_deleter< T, AllocatorStorage >::allocator_deleter ( AllocatorStorage  storage)
explicit

Constructs an allocator_deleter that uses the referenced allocator for deletion.

Parameters
storagethe allocator storage

◆ allocator_deleter() [2/3]

template<typename T , typename AllocatorStorage >
bit::memory::allocator_deleter< T, AllocatorStorage >::allocator_deleter ( allocator_deleter< T, AllocatorStorage > &&  other)
defaultnoexcept

Move-constructs an allocator_deleter from an existing one.

Parameters
otherthe other allocator_delete to move

◆ allocator_deleter() [3/3]

template<typename T , typename AllocatorStorage >
bit::memory::allocator_deleter< T, AllocatorStorage >::allocator_deleter ( const allocator_deleter< T, AllocatorStorage > &  other)
defaultnoexcept

Copy-constructs the allocator_deleter from an existing one.

Parameters
otherthe other allocator deleter to copy

Member Function Documentation

◆ operator()()

template<typename T , typename AllocatorStorage >
void bit::memory::allocator_deleter< T, AllocatorStorage >::operator() ( pointer  p)

Deletes the underlying pointer p.

Parameters
pthe pointer to delete

◆ operator=() [1/2]

template<typename T , typename AllocatorStorage >
allocator_deleter& bit::memory::allocator_deleter< T, AllocatorStorage >::operator= ( allocator_deleter< T, AllocatorStorage > &&  other)
defaultnoexcept

Move-assigns an allocator_deleter from an existing one.

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

◆ operator=() [2/2]

template<typename T , typename AllocatorStorage >
allocator_deleter& bit::memory::allocator_deleter< T, AllocatorStorage >::operator= ( const allocator_deleter< T, AllocatorStorage > &  other)
defaultnoexcept

Copy-assigns an allocator_deleter from an existing one.

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

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