1#ifndef ZSERIO_UNIQUE_PTR_H_INC
2#define ZSERIO_UNIQUE_PTR_H_INC
19template <
class ALLOC_T>
20struct UniquePtrDeleter :
public AllocatorHolder<ALLOC_T>
23 using T =
typename allocator_type::value_type;
27 ~UniquePtrDeleter() =
default;
29 UniquePtrDeleter(UniquePtrDeleter&& other) =
default;
30 UniquePtrDeleter&
operator=(UniquePtrDeleter&& other) =
default;
39 UniquePtrDeleter(
const UniquePtrDeleter& other) =
delete;
40 UniquePtrDeleter&
operator=(
const UniquePtrDeleter& other) =
delete;
49 UniquePtrDeleter(ALLOC_T())
55 UniquePtrDeleter(
const ALLOC_T& allocator) :
59 void operator()(T* ptr)
62 using AllocTraits = std::allocator_traits<allocator_type>;
63 AllocTraits::destroy(alloc, std::addressof(*ptr));
64 AllocTraits::deallocate(alloc, ptr, 1);
75template <
typename T,
typename ALLOC = std::allocator<T>>
76using UniquePtr = std::unique_ptr<T, detail::UniquePtrDeleter<ALLOC>>;
87template <
typename T,
typename ALLOC,
class...
Args>
91 using AllocTraits = std::allocator_traits<Allocator>;
allocator_type get_allocator() const
AllocatorHolder & operator=(const AllocatorHolder &other)=default
std::unique_ptr< T, detail::UniquePtrDeleter< ALLOC > > UniquePtr
UniquePtr< T, RebindAlloc< ALLOC, T > > allocate_unique(const ALLOC &allocator, Args &&... args)