From 69e2eccf687616ea3c6f1d233dc576f7a9acbbbf Mon Sep 17 00:00:00 2001 From: Tomasz Grabiec Date: Mon, 22 May 2017 10:39:33 +0200 Subject: [PATCH] allocating_strategy: Introduce alloc_strategy_unique_ptr<> --- utils/allocation_strategy.hh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/utils/allocation_strategy.hh b/utils/allocation_strategy.hh index b69073bb3d..218dd14dd3 100644 --- a/utils/allocation_strategy.hh +++ b/utils/allocation_strategy.hh @@ -203,6 +203,19 @@ auto current_deleter() { }; } +template +struct alloc_strategy_deleter { + void operator()(T* ptr) const noexcept { + current_allocator().destroy(ptr); + } +}; + +// std::unique_ptr which can be used for owning an object allocated using allocation_strategy. +// Must be destroyed before the pointer is invalidated. For compacting allocators, that +// means it must not escape outside allocating_section or reclaim lock. +// Must be destroyed in the same allocating context in which T was allocated. +template +using alloc_strategy_unique_ptr = std::unique_ptr>; // // Passing allocators to objects.