allocating_strategy: Introduce alloc_strategy_unique_ptr<>

This commit is contained in:
Tomasz Grabiec
2017-05-22 10:39:33 +02:00
parent 3fc1703ccf
commit 69e2eccf68

View File

@@ -203,6 +203,19 @@ auto current_deleter() {
};
}
template<typename T>
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<typename T>
using alloc_strategy_unique_ptr = std::unique_ptr<T, alloc_strategy_deleter<T>>;
//
// Passing allocators to objects.