From b36d072ad7a7b9c6e30fcb25d6bbb001a8393468 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 10 Apr 2022 17:20:49 +0200 Subject: refactor: add factory class & make DI container return unique ptrs --- src/DI/allocation.hpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/DI/allocation.hpp (limited to 'src/DI/allocation.hpp') diff --git a/src/DI/allocation.hpp b/src/DI/allocation.hpp new file mode 100644 index 0000000..ac0fa38 --- /dev/null +++ b/src/DI/allocation.hpp @@ -0,0 +1,32 @@ +#pragma once + +#include + +template +struct RebindAllocHelper +{ + using type = typename Traits::template rebind_alloc; +}; + +template +class AllocDestructor +{ + using _alloc_traits = std::allocator_traits; + +public: + using Pointer = typename _alloc_traits::pointer; + using Size = typename _alloc_traits::size_type; + + using pointer = Pointer; + using size = Size; + + AllocDestructor(Allocator &allocator, Size alloc_size) noexcept; + + void operator()(Pointer ptr) noexcept; + +private: + Allocator &_allocator; + Size _size; +}; + +#include "allocation.tpp" -- cgit v1.2.3-18-g5258