diff options
-rw-r--r-- | src/handle-page.hpp | 1 | ||||
-rw-r--r-- | src/handle-page.inl | 4 | ||||
-rw-r--r-- | test/handle.cpp | 8 |
3 files changed, 12 insertions, 1 deletions
diff --git a/src/handle-page.hpp b/src/handle-page.hpp index 057a512e..bf7ecdad 100644 --- a/src/handle-page.hpp +++ b/src/handle-page.hpp @@ -9,6 +9,7 @@ namespace floormat::impl_handle { template<typename Obj, uint32_t PageSize> struct Item { + ~Item() noexcept; union { char empty = {}; Obj object; }; Handle<Obj, PageSize> handle; uint32_t next; diff --git a/src/handle-page.inl b/src/handle-page.inl index 8a8bd489..70837e0c 100644 --- a/src/handle-page.inl +++ b/src/handle-page.inl @@ -6,6 +6,10 @@ namespace floormat::impl_handle { template<typename Obj, uint32_t PageSize> +Item<Obj, PageSize>::~Item() noexcept +{} + +template<typename Obj, uint32_t PageSize> void Page<Obj, PageSize>::do_deallocate(Item<Obj, PageSize>& item) { item.object.~Obj(); diff --git a/test/handle.cpp b/test/handle.cpp index 2b52b04e..563e56ae 100644 --- a/test/handle.cpp +++ b/test/handle.cpp @@ -8,7 +8,13 @@ namespace floormat { namespace { constexpr uint32_t start_index = 1024, page_size = 128; -struct Foo { int value = 0; }; + +struct Foo +{ + int value = 0; + ~Foo() { value = 0; } +}; + using Page = impl_handle::Page<Foo, page_size>; using Handle = impl_handle::Handle<Foo, page_size>; |