1 #ifndef ZSERIO_PPMR_PROPAGATING_POLYMORPHIC_ALLOCATOR_H_INC
2 #define ZSERIO_PPMR_PROPAGATING_POLYMORPHIC_ALLOCATOR_H_INC
5 #include <memory_resource>
36 std::pmr::memory_resource*
resource = std::pmr::get_default_resource()) noexcept :
63 m_resource(other.resource())
74 m_resource = other.resource();
105 template <
typename U,
typename... Args>
108 using Self = decltype(*
this);
109 if constexpr (std::uses_allocator_v<std::remove_cv_t<U>, Self>)
111 if constexpr (std::is_constructible_v<U, std::allocator_arg_t, Self, Args...>)
113 new (
static_cast<void*
>(ptr)) U(std::allocator_arg, *
this, std::forward<Args>(args)...);
117 new (
static_cast<void*
>(ptr)) U(std::forward<Args>(args)..., *
this);
122 new (
static_cast<void*
>(ptr)) U(std::forward<Args>(args)...);
131 template <
typename U>
132 void destroy(U* ptr) noexcept(noexcept(ptr->~U()))
148 std::pmr::memory_resource*
resource() const noexcept
154 std::pmr::memory_resource* m_resource;
157 template <
class T,
class U>
161 return *lhs.
resource() == *rhs.resource();
164 template <
class T,
class U>
168 return !(lhs == rhs);
void construct(U *ptr, Args &&... args)
PropagatingPolymorphicAllocator & operator=(PropagatingPolymorphicAllocator &&other) noexcept=default
PropagatingPolymorphicAllocator(const PropagatingPolymorphicAllocator &other) noexcept=default
PropagatingPolymorphicAllocator(const PropagatingPolymorphicAllocator< U > &other) noexcept
PropagatingPolymorphicAllocator select_on_container_copy_construction() const
void destroy(U *ptr) noexcept(noexcept(ptr->~U()))
PropagatingPolymorphicAllocator(std::pmr::memory_resource *resource=std::pmr::get_default_resource()) noexcept
std::true_type propagate_on_container_copy_assignment
PropagatingPolymorphicAllocator & operator=(const PropagatingPolymorphicAllocator &other) noexcept=default
~PropagatingPolymorphicAllocator()=default
std::true_type propagate_on_container_move_assignment
value_type * allocate(std::size_t size)
std::pmr::memory_resource * resource() const noexcept
PropagatingPolymorphicAllocator(PropagatingPolymorphicAllocator &&other) noexcept=default
std::true_type propagate_on_container_swap
PropagatingPolymorphicAllocator & operator=(const PropagatingPolymorphicAllocator< U > &other) noexcept
void deallocate(value_type *memory, std::size_t size) noexcept
bool operator==(const PropagatingPolymorphicAllocator< T > &lhs, const PropagatingPolymorphicAllocator< U > &rhs) noexcept
bool operator!=(const PropagatingPolymorphicAllocator< T > &lhs, const PropagatingPolymorphicAllocator< U > &rhs) noexcept