memory
allocator_polymorphic_deleter< BaseType, RawAllocator > Class Template Reference

Detailed Description

template<typename BaseType, class RawAllocator>
class foonathan::memory::allocator_polymorphic_deleter< BaseType, RawAllocator >

Similar to allocator_polymorphic_deallocator but calls the destructors of the object.

Otherwise behaves the same.

Note
It has a relatively high space overhead, so only use it if you have to.

Typedefs

using allocator_type
 
using value_type
 

Member Functions

 allocator_polymorphic_deleter () noexcept=default
 
template<typename T>
 allocator_polymorphic_deleter (allocator_deleter< T, RawAllocator > deleter)
 
void operator() (value_type *pointer) noexcept
 
auto get_allocator () const noexcept -> decltype(std::declval< allocator_reference< allocator_type > >().get_allocator())
 

Constructors

◆ allocator_polymorphic_deleter() [1/2]

template<typename BaseType, class RawAllocator>
allocator_polymorphic_deleter ( )
defaultnoexcept
Effects:
Creates it without any associated allocator. The deleter must not be used if that is the case.
Notes:
This functions is useful if you have want to create an empty smart pointer without giving it an allocator.

◆ allocator_polymorphic_deleter() [2/2]

template<typename BaseType, class RawAllocator>
template<typename T>
allocator_polymorphic_deleter ( allocator_deleter< T, RawAllocator > deleter)
Effects:
Creates it from a deleter for a derived type. It will deallocate the memory as if done by the derived type.

Member Functions

◆ operator()()

template<typename BaseType, class RawAllocator>
void operator() ( value_type * pointer)
noexcept
Effects:
Deallocates the memory given to it. Calls deallocate_node(pointer, size, alignment) on the referenced allocator object, where size and alignment are the values of the type it was created with.

◆ get_allocator()

template<typename BaseType, class RawAllocator>
auto get_allocator ( ) const -> decltype(std::declval<allocator_reference<allocator_type>>().get_allocator())
noexcept
Returns:
The reference to the allocator. It has the same type as the call to get_allocator().