diff --git a/src/lib/several-builder.hpp b/src/lib/several-builder.hpp index 4da1e1e12..8c3309a0e 100644 --- a/src/lib/several-builder.hpp +++ b/src/lib/several-builder.hpp @@ -73,36 +73,44 @@ namespace lib { - template - struct DeleterTrampoline + template class ALO> + struct ElementFactory + : private ALO { - using Allo = std::allocator; + using Allo = ALO; using AlloT = std::allocator_traits; + Allo& baseAllocator() { return *this; } + template - static auto + auto adaptAllocator() { using XAllo = typename AlloT::template rebind_alloc; if constexpr (std::is_constructible_v) - return XAllo{Allo()}; + return XAllo{baseAllocator()}; else return XAllo{}; } - static void + ElementFactory (Allo allo = Allo{}) + : Allo{std::move (allo)} + { } + + template + void destroy (ArrayBucket* bucket, size_t size) { - Allo allo{}; + REQUIRE (bucket); + using ElmAlloT = typename AlloT::template rebind_traits; + auto elmAllo = adaptAllocator(); for (size_t i=0; isubscript(i)); + ElmAlloT::destroy (elmAllo, & bucket->subscript(i)); size_t storageBytes = sizeof(ArrayBucket) - sizeof(ArrayBucket::storage) - + size * sizeof(E); + + size * bucket->spread; - using BAlloT = typename AlloT::template rebind_traits; - auto bAllo = adaptAllocator(); - BAlloT::deallocate (bAllo, bucket, storageBytes); + AlloT::deallocate (baseAllocator(), bucket, storageBytes); }; }; diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index d0c69aaba..6d8fab0e4 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -81975,6 +81975,11 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
+ + + + + @@ -82231,7 +82236,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + @@ -82251,6 +82256,11 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
+ + + + +