aboutsummaryrefslogtreecommitdiff
path: root/include/yacppdic/detail/internal/alloc_destructor.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/yacppdic/detail/internal/alloc_destructor.hpp')
-rw-r--r--include/yacppdic/detail/internal/alloc_destructor.hpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/include/yacppdic/detail/internal/alloc_destructor.hpp b/include/yacppdic/detail/internal/alloc_destructor.hpp
new file mode 100644
index 0000000..9160b8b
--- /dev/null
+++ b/include/yacppdic/detail/internal/alloc_destructor.hpp
@@ -0,0 +1,37 @@
+#pragma once
+
+#include <memory>
+
+namespace yacppdic::internal
+{
+
+template <class Traits, class Type>
+struct RebindAllocHelper
+{
+ using type = typename Traits::template rebind_alloc<Type>;
+};
+
+template <class Allocator>
+class AllocDestructor
+{
+ using _alloc_traits = std::allocator_traits<Allocator>;
+
+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;
+};
+
+} // namespace yacppdic::internal
+
+#include "alloc_destructor-impl.hpp"