From ffd173334d47e5cc4e83abeaebe1213810f3822c Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Sat, 21 Oct 2023 18:33:11 -0400 Subject: [PATCH] [hive] Remove the non-P2596 API --- README.md | 4 +- include/sg14/hive.h | 187 ---------------------------------- test/hive_test.cpp | 243 +------------------------------------------- 3 files changed, 5 insertions(+), 429 deletions(-) diff --git a/README.md b/README.md index a656ade..7981c7d 100644 --- a/README.md +++ b/README.md @@ -251,7 +251,9 @@ and erasure. [`plf::hive`](https://github.com/mattreecebentley/plf_hive), formerly known as [`plf::colony`](https://github.com/mattreecebentley/plf_colony). `hive` was proposed in -[P0447](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p0447r20.html). +[P0447](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p0447r23.html). +This version incorporates API changes proposed in +[P2596](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2596r0.html). ## How to build diff --git a/include/sg14/hive.h b/include/sg14/hive.h index de13767..f73101a 100644 --- a/include/sg14/hive.h +++ b/include/sg14/hive.h @@ -21,10 +21,6 @@ #pragma once -#ifndef SG14_HIVE_P2596 - #define SG14_HIVE_P2596 1 -#endif - #ifndef SG14_HIVE_RANDOM_ACCESS_ITERATORS #define SG14_HIVE_RANDOM_ACCESS_ITERATORS 0 #endif @@ -100,13 +96,6 @@ static inline void hive_try_finally(F&& task, R&& finally) { task(); } -#if !SG14_HIVE_P2596 -struct hive_limits { - constexpr hive_limits(size_t mn, size_t mx) noexcept : min(mn), max(mx) {} - size_t min, max; -}; -#endif - namespace hive_priority { struct performance { using skipfield_type = unsigned short; @@ -724,9 +713,6 @@ class hive { void assert_invariants() const { #if SG14_HIVE_DEBUGGING assert(size_ <= capacity_); -#if !SG14_HIVE_P2596 - assert(min_group_capacity_ <= max_group_capacity_); -#endif if (size_ == 0) { assert(begin_ == end_); if (capacity_ == 0) { // TODO FIXME BUG HACK: this should be `if (true)` @@ -757,10 +743,6 @@ class hive { size_type total_size = 0; size_type total_cap = 0; for (GroupPtr g = begin_.group_; g != nullptr; g = g->next_group) { -#if !SG14_HIVE_P2596 - assert(min_group_capacity_ <= g->capacity); - assert(g->capacity <= max_group_capacity_); -#endif // assert(g->size >= 1); // TODO FIXME BUG HACK assert(g->size <= g->capacity); total_size += g->size; @@ -807,10 +789,6 @@ class hive { assert(total_size == size_); assert((unused_groups_ != nullptr) == (unused_groups_tail_ != nullptr)); for (GroupPtr g = unused_groups_; g != nullptr; g = g->next_group) { -#if !SG14_HIVE_P2596 - assert(min_group_capacity_ <= g->capacity); - assert(g->capacity <= max_group_capacity_); -#endif total_cap += g->capacity; if (g->next_group == nullptr) { assert(unused_groups_tail_ == g); @@ -836,11 +814,7 @@ class hive { "hive [%zu/%zu used] (erase=%p, unused=%p, mincap=%zu, maxcap=%zu)\n", size_t(size_), size_t(capacity_), groups_with_erasures_, unused_groups_, -#if SG14_HIVE_P2596 size_t(impl_min_block_size()), size_t(impl_max_block_size()) -#else - size_t(min_group_capacity_), size_t(max_group_capacity_) -#endif ); printf(" begin="); begin_.debug_dump(); size_t total = 0; @@ -879,19 +853,6 @@ class hive { size_type size_ = 0; size_type capacity_ = 0; allocator_type allocator_; -#if !SG14_HIVE_P2596 - skipfield_type min_group_capacity_ = block_capacity_hard_limits().min; - skipfield_type max_group_capacity_ = block_capacity_hard_limits().max; -#endif - -#if !SG14_HIVE_P2596 - static inline void check_limits(sg14::hive_limits soft) { - auto hard = block_capacity_hard_limits(); - if (!(hard.min <= soft.min && soft.min <= soft.max && soft.max <= hard.max)) { - SG14_HIVE_THROW(std::length_error("Supplied limits are outside the allowable range")); - } - } -#endif size_type trailing_capacity() const { if (end_.group_ == nullptr) { @@ -927,39 +888,12 @@ class hive { explicit hive(const allocator_type &alloc) : allocator_(alloc) {} hive(const hive& h) : hive(h, std::allocator_traits::select_on_container_copy_construction(h.allocator_)) {} -#if SG14_HIVE_P2596 hive(const hive& h, const hive_identity_t& alloc) : allocator_(alloc) { reserve(h.size()); range_assign_impl(h.begin(), h.end()); } -#else - explicit hive(sg14::hive_limits limits) : - min_group_capacity_(static_cast(limits.min)), - max_group_capacity_(static_cast(limits.max)) - { - check_limits(limits); - } - - hive(sg14::hive_limits limits, const allocator_type &alloc) : - allocator_(alloc), - min_group_capacity_(static_cast(limits.min)), - max_group_capacity_(static_cast(limits.max)) - { - check_limits(limits); - } - - hive(const hive& source, const hive_identity_t& alloc) : - allocator_(alloc), - min_group_capacity_(static_cast((source.min_group_capacity_ > source.size_) ? source.min_group_capacity_ : ((source.size_ > source.max_group_capacity_) ? source.max_group_capacity_ : source.size_))), - max_group_capacity_(source.max_group_capacity_) - { - reserve(source.size()); - range_assign_impl(source.begin(), source.end()); - min_group_capacity_ = source.min_group_capacity_; - } -#endif hive(hive&& source) noexcept : end_(std::move(source.end_)), @@ -969,10 +903,6 @@ class hive { size_(source.size_), capacity_(source.capacity_), allocator_(source.get_allocator()) -#if !SG14_HIVE_P2596 - , min_group_capacity_(source.min_group_capacity_) - , max_group_capacity_(source.max_group_capacity_) -#endif { assert(&source != this); source.blank(); @@ -988,9 +918,6 @@ class hive { if (should_use_source_allocator) { *this = std::move(source); } else { -#if !SG14_HIVE_P2596 - reshape(source.block_capacity_limits()); -#endif reserve(source.size()); range_assign_impl(std::make_move_iterator(source.begin()), std::make_move_iterator(source.end())); } @@ -1029,45 +956,6 @@ class hive { assign(il.begin(), il.end()); } -#if !SG14_HIVE_P2596 - hive(size_type n, const T& value, sg14::hive_limits limits, const allocator_type &alloc = allocator_type()) : - allocator_(alloc), - min_group_capacity_(static_cast(limits.min)), - max_group_capacity_(static_cast(limits.max)) - { - check_limits(limits); - assign(n, value); - } - - hive(size_type n, sg14::hive_limits limits, const allocator_type &alloc = allocator_type()) : - allocator_(alloc), - min_group_capacity_(static_cast(limits.min)), - max_group_capacity_(static_cast(limits.max)) - { - check_limits(limits); - assign(n, T()); - } - - template::value>> - hive(It first, It last, sg14::hive_limits limits, const allocator_type &alloc = allocator_type()) : - allocator_(alloc), - min_group_capacity_(static_cast(limits.min)), - max_group_capacity_(static_cast(limits.max)) - { - check_limits(limits); - assign(std::move(first), std::move(last)); - } - - hive(std::initializer_list il, sg14::hive_limits limits, const allocator_type &alloc = allocator_type()): - allocator_(alloc), - min_group_capacity_(static_cast(limits.min)), - max_group_capacity_(static_cast(limits.max)) - { - check_limits(limits); - assign(il.begin(), il.end()); - } -#endif - #if __cpp_lib_ranges >= 201911L && __cpp_lib_ranges_to_container >= 202202L template requires std::convertible_to, T> @@ -1083,19 +971,6 @@ class hive { { assign_range(std::forward(rg)); } - -#if !SG14_HIVE_P2596 - template - requires std::convertible_to, T> - explicit hive(std::from_range_t, R&& rg, sg14::hive_limits limits, const allocator_type &alloc = allocator_type()) : - allocator_(alloc), - min_group_capacity_(static_cast(limits.min)), - max_group_capacity_(static_cast(limits.max)) - { - check_limits(limits); - assign_range(std::forward(rg)); - } -#endif // !SG14_HIVE_P2596 #endif // __cpp_lib_ranges >= 201911L && __cpp_lib_ranges_to_container >= 202202L ~hive() { @@ -1680,10 +1555,6 @@ class hive { swap(unused_groups_tail_, source.unused_groups_tail_); swap(size_, source.size_); swap(capacity_, source.capacity_); -#if !SG14_HIVE_P2596 - swap(min_group_capacity_, source.min_group_capacity_); - swap(max_group_capacity_, source.max_group_capacity_); -#endif if constexpr (std::allocator_traits::propagate_on_container_swap::value && !std::allocator_traits::is_always_equal::value) { swap(allocator_, source.allocator_); } @@ -1722,16 +1593,6 @@ class hive { SG14_HIVE_THROW(std::length_error("Result of splice would exceed max_size()")); } -#if !SG14_HIVE_P2596 - if (source.min_group_capacity_ < min_group_capacity_ || source.max_group_capacity_ > max_group_capacity_) { - for (GroupPtr it = source.begin_.group_; it != nullptr; it = it->next_group) { - if (it->capacity < min_group_capacity_ || it->capacity > max_group_capacity_) { - SG14_HIVE_THROW(std::length_error("Cannot splice: source hive contains blocks that do not match the block limits of the destination hive")); - } - } - } -#endif - size_type trailing = trailing_capacity(); if (trailing > source.trailing_capacity()) { source.splice(*this); @@ -2083,13 +1944,11 @@ class hive { inline size_type max_size() const noexcept { return std::allocator_traits::max_size(get_allocator()); } inline size_type capacity() const noexcept { return capacity_; } -#if SG14_HIVE_P2596 inline size_type max_block_size() const noexcept { size_type a = impl_max_block_size(); size_type b = max_size(); return a < b ? a : b; } -#endif private: static inline size_type impl_min_block_size() { return 3; } @@ -2098,12 +1957,7 @@ class hive { inline size_type recommend_block_size() const { size_type r = size_; if (r < 8) r = 8; -#if SG14_HIVE_P2596 if (r > impl_max_block_size()) r = impl_max_block_size(); -#else - if (r < min_group_capacity_) r = min_group_capacity_; - if (r > max_group_capacity_) r = max_group_capacity_; -#endif return r; } @@ -2188,7 +2042,6 @@ class hive { } public: -#if SG14_HIVE_P2596 bool reshape(size_type min, size_type n = 0) { if (n > max_size()) { SG14_HIVE_THROW(std::length_error("n must be at most max_size()")); @@ -2224,33 +2077,6 @@ class hive { return true; } } -#else - void reshape(sg14::hive_limits limits) { - check_limits(limits); - assert_invariants(); - - reshape_impl_deallocate_unused_groups(limits.min, limits.max); - - for (GroupPtr g = begin_.group_; g != nullptr; g = g->next_group) { - if (g->capacity < limits.min || g->capacity > limits.max) { - hive temp(limits, get_allocator()); - temp.range_assign_impl(std::make_move_iterator(begin()), std::make_move_iterator(end())); - this->swap(temp); - return; - } - } - min_group_capacity_ = limits.min; - max_group_capacity_ = limits.max; - } - - inline sg14::hive_limits block_capacity_limits() const noexcept { - return sg14::hive_limits(min_group_capacity_, max_group_capacity_); - } - - static constexpr sg14::hive_limits block_capacity_hard_limits() noexcept { - return sg14::hive_limits(impl_min_block_size(), std::numeric_limits::max()); - } -#endif hive& operator=(const hive& source) { if constexpr (std::allocator_traits::propagate_on_container_copy_assignment::value) { @@ -2295,10 +2121,6 @@ class hive { unused_groups_tail_ = std::move(source.unused_groups_tail_); size_ = source.size_; capacity_ = source.capacity_; -#if !SG14_HIVE_P2596 - min_group_capacity_ = source.min_group_capacity_; - max_group_capacity_ = source.max_group_capacity_; -#endif if constexpr (std::allocator_traits::propagate_on_container_move_assignment::value) { allocator_ = std::move(source.allocator_); } @@ -2321,13 +2143,8 @@ class hive { } void shrink_to_fit() { -#if SG14_HIVE_P2596 const size_type min = impl_min_block_size(); const size_type max = impl_max_block_size(); -#else - const size_type min = min_group_capacity_; - const size_type max = max_group_capacity_; -#endif trim_capacity(); size_type oldsize = size(); hive other(get_allocator()); @@ -2372,11 +2189,7 @@ class hive { } void reserve(size_type n) { -#if SG14_HIVE_P2596 reserve_impl(n, impl_min_block_size(), impl_max_block_size()); -#else - reserve_impl(n, min_group_capacity_, max_group_capacity_); -#endif } private: diff --git a/test/hive_test.cpp b/test/hive_test.cpp index 20a55d0..0a6f8db 100644 --- a/test/hive_test.cpp +++ b/test/hive_test.cpp @@ -60,17 +60,12 @@ template struct hivet_setup template H make_rope(size_t blocksize, size_t cap) { -#if SG14_HIVE_P2596 H h; for (size_t i=0; i < cap; i += blocksize) { H temp; temp.reserve(blocksize); h.splice(temp); } -#else - H h(sg14::hive_limits(blocksize, blocksize)); - h.reserve(cap); -#endif return h; } @@ -106,9 +101,8 @@ H make_rope(size_t blocksize, size_t cap) EXPECT_EQ(jt.prev(n), it); #endif -TEST(hive, OutOfRangeReshapeByP2596) +TEST(hive, OutOfRangeReshape) { -#if SG14_HIVE_P2596 sg14::hive h; h.reshape(0); h.reshape(0, 0); @@ -119,62 +113,6 @@ TEST(hive, OutOfRangeReshapeByP2596) ASSERT_THROW(h.reshape(h.max_block_size() + 1), std::length_error); ASSERT_THROW(h.reshape(h.max_block_size() + 1, 0), std::length_error); ASSERT_THROW(h.reshape(0, h.max_size() + 1), std::length_error); -#endif -} - -TEST(hive, OutOfRangeLimitsByP0447) -{ -#if !SG14_HIVE_P2596 - using H = sg14::hive; - size_t min = H::block_capacity_hard_limits().min; - size_t max = H::block_capacity_hard_limits().max; - EXPECT_LE(min, max); - ASSERT_GT(min, min-1); - ASSERT_LT(max, max+1); - - // These ranges are valid and overlap a physically possible range; - // the implementation COULD just clamp them to the possible range. - // Instead, P0447R20 says the behavior is undefined. - - ASSERT_THROW(H(sg14::hive_limits(min-1, max)), std::length_error); - ASSERT_THROW(H(sg14::hive_limits(min, max+1)), std::length_error); - ASSERT_THROW(H(sg14::hive_limits(min-1, max+1)), std::length_error); - ASSERT_THROW(H(sg14::hive_limits(min-1, min)), std::length_error); - ASSERT_THROW(H(sg14::hive_limits(max, max+1)), std::length_error); - - H h; - ASSERT_THROW(h.reshape({min-1, max}), std::length_error); - ASSERT_THROW(h.reshape({min, max+1}), std::length_error); - ASSERT_THROW(h.reshape({min-1, max+1}), std::length_error); - ASSERT_THROW(h.reshape({min-1, min}), std::length_error); - ASSERT_THROW(h.reshape({max, max+1}), std::length_error); -#endif -} - -TEST(hive, OutOfRangeLimitsByMath) -{ -#if !SG14_HIVE_P2596 - using H = sg14::hive; - size_t min = H::block_capacity_hard_limits().min; - size_t max = H::block_capacity_hard_limits().max; - EXPECT_LE(min, max); - ASSERT_GT(min, min-1); - ASSERT_LT(max, max+1); - - // These ranges are invalid, or physically impossible to enforce. - // P0447R20 says the behavior is undefined in these cases as well. - - ASSERT_THROW(H(sg14::hive_limits(min-1, min-1)), std::length_error); - ASSERT_THROW(H(sg14::hive_limits(max+1, max+1)), std::length_error); - ASSERT_THROW(H(sg14::hive_limits(max, max-1)), std::length_error); - ASSERT_THROW(H(sg14::hive_limits(min+1, min)), std::length_error); - - H h; - ASSERT_THROW(h.reshape({min-1, min-1}), std::length_error); - ASSERT_THROW(h.reshape({max+1, max+1}), std::length_error); - ASSERT_THROW(h.reshape({max, max-1}), std::length_error); - ASSERT_THROW(h.reshape({min+1, min}), std::length_error); -#endif } TYPED_TEST(hivet, BasicInsertClear) @@ -327,17 +265,9 @@ TEST(hive, ReshapeWithThrow) sg14::hive h = make_rope>(9, 20); h.insert(20, S(&should_throw, 42)); EXPECT_EQ(h.size(), 20u); -#if !SG14_HIVE_P2596 - EXPECT_EQ(h.block_capacity_limits().min, 9); - EXPECT_EQ(h.block_capacity_limits().max, 9); -#endif try { should_throw = t; -#if SG14_HIVE_P2596 h.reshape(6); -#else - h.reshape({6, 6}); -#endif EXPECT_EQ(h.size(), 20u); EXPECT_INVARIANTS(h); break; @@ -349,56 +279,17 @@ TEST(hive, ReshapeWithThrow) } } -TEST(hive, ReshapeUnusedBlocksP2596) -{ -#if SG14_HIVE_P2596 - sg14::hive h = make_rope>(9, 42); - h.insert(42, 'x'); - h.erase(h.begin(), h.begin().next(20)); - EXPECT_EQ(h.size(), 22u); - EXPECT_EQ(h.capacity(), 45u); - EXPECT_INVARIANTS(h); - h.reshape(10); - EXPECT_EQ(h.size(), 22u); - EXPECT_INVARIANTS(h); -#endif -} - TEST(hive, ReshapeUnusedBlocks) { -#if !SG14_HIVE_P2596 sg14::hive h = make_rope>(9, 42); h.insert(42, 'x'); h.erase(h.begin(), h.begin().next(20)); EXPECT_EQ(h.size(), 22u); EXPECT_EQ(h.capacity(), 45u); EXPECT_INVARIANTS(h); - h.reshape({6, 6}); + h.reshape(10); EXPECT_EQ(h.size(), 22u); - EXPECT_EQ(h.capacity(), 24u); - EXPECT_INVARIANTS(h); -#endif -} - -TEST(hive, ReshapeUnusedBlocks2) -{ -#if !SG14_HIVE_P2596 - sg14::hive h; - h.reshape({6, 9}); - h.splice(sg14::hive{1,2,3,4,5,6,7,8,9}); - h.splice(sg14::hive{1,2,3,4,5,6}); - h.splice(sg14::hive{1,2,3,4,5,6}); - h.splice(sg14::hive{1,2,3,4,5,6,7,8,9}); - h.erase(h.begin(), h.begin().next(10)); - h.erase(h.end().prev(10), h.end()); - EXPECT_EQ(h.size(), 10u); - EXPECT_EQ(h.capacity(), 30u); - EXPECT_INVARIANTS(h); - h.reshape({6, 6}); - EXPECT_EQ(h.size(), 10u); - EXPECT_EQ(h.capacity(), 12u); EXPECT_INVARIANTS(h); -#endif } TYPED_TEST(hivet, CustomAdvanceForward) @@ -1324,11 +1215,7 @@ TEST(hive, InsertAndErase2) { std::mt19937 g; sg14::hive h; -#if SG14_HIVE_P2596 h.reshape(10'000, 30'000); -#else - h.reshape(sg14::hive_limits(10'000, h.block_capacity_limits().max)); -#endif h.insert(30'000, 1); EXPECT_EQ(h.size(), 30'000u); EXPECT_INVARIANTS(h); @@ -2228,71 +2115,6 @@ TEST(hive, NonCopyable) EXPECT_EQ((++h.begin())->m, 2); } -TEST(hive, Reshape) -{ -#if !SG14_HIVE_P2596 - sg14::hive h; - h.reshape(sg14::hive_limits(50, 100)); - EXPECT_EQ(h.block_capacity_limits().min, 50u); - EXPECT_EQ(h.block_capacity_limits().max, 100u); - EXPECT_TRUE(h.empty()); - EXPECT_INVARIANTS(h); - - h.insert(27); - EXPECT_EQ(h.size(), 1u); - EXPECT_EQ(h.capacity(), 50u); - EXPECT_INVARIANTS(h); - - for (int i = 0; i < 100; ++i) { - h.insert(i); - } - EXPECT_EQ(h.size(), 101u); - EXPECT_EQ(h.capacity(), 200u); - EXPECT_INVARIANTS(h); - - h.clear(); - h.reshape(sg14::hive_limits(200, 2000)); - EXPECT_TRUE(h.empty()); - EXPECT_EQ(h.block_capacity_limits().min, 200u); - EXPECT_EQ(h.block_capacity_limits().max, 2000u); - EXPECT_INVARIANTS(h); - - h.insert(27); - EXPECT_EQ(h.size(), 1u); - EXPECT_EQ(h.capacity(), 200u); - EXPECT_INVARIANTS(h); - - static_assert(noexcept(h.block_capacity_limits()), ""); - sg14::hive_limits soft = h.block_capacity_limits(); - EXPECT_EQ(soft.min, 200u); - EXPECT_EQ(soft.max, 2000u); - - static_assert(noexcept(decltype(h)::block_capacity_hard_limits()), ""); - sg14::hive_limits hard = decltype(h)::block_capacity_hard_limits(); - EXPECT_EQ(hard.min, 3u); - EXPECT_EQ(hard.max, 65535u); - - for (int i = 0; i < 3300; ++i) { - h.insert(i); - } - EXPECT_EQ(h.size(), 3301u); - EXPECT_EQ(h.capacity(), 5200u); - EXPECT_INVARIANTS(h); - - h.reshape(sg14::hive_limits(500, 500)); - EXPECT_EQ(h.block_capacity_limits().min, 500u); - EXPECT_EQ(h.block_capacity_limits().max, 500u); - EXPECT_EQ(h.size(), 3301u); - EXPECT_EQ(h.capacity(), 3500u); - EXPECT_INVARIANTS(h); - - h.reshape(sg14::hive_limits(200, 200)); - EXPECT_EQ(h.size(), 3301u); - EXPECT_EQ(h.capacity(), 3400u); - EXPECT_INVARIANTS(h); -#endif -} - TEST(hive, SpliceLvalue) { std::vector v1 = {1, 2, 3}; @@ -2308,19 +2130,6 @@ TEST(hive, SpliceLvalue) EXPECT_INVARIANTS(h2); static_assert(!noexcept(h1.splice(h2))); - -#if !SG14_HIVE_P2596 - // Test the throwing case - h1.reshape({5, 5}); - h2.reshape({10, 10}); - v2 = {15, 16, 17}; - h2 = {15, 16, 17}; - EXPECT_THROW(h1.splice(h2), std::length_error); - EXPECT_INVARIANTS(h1); - EXPECT_INVARIANTS(h2); - EXPECT_TRUE(std::is_permutation(h1.begin(), h1.end(), v1.begin(), v1.end())); - EXPECT_TRUE(std::is_permutation(h2.begin(), h2.end(), v2.begin(), v2.end())); -#endif } TEST(hive, SpliceRvalue) @@ -2338,19 +2147,6 @@ TEST(hive, SpliceRvalue) EXPECT_INVARIANTS(h2); static_assert(!noexcept(h1.splice(std::move(h2)))); - -#if !SG14_HIVE_P2596 - // Test the throwing case - h1.reshape({5, 5}); - h2.reshape({10, 10}); - v2 = {15, 16, 17}; - h2 = {15, 16, 17}; - EXPECT_THROW(h1.splice(std::move(h2)), std::length_error); - EXPECT_INVARIANTS(h1); - EXPECT_INVARIANTS(h2); - EXPECT_TRUE(std::is_permutation(h1.begin(), h1.end(), v1.begin(), v1.end())); - EXPECT_TRUE(std::is_permutation(h2.begin(), h2.end(), v2.begin(), v2.end())); -#endif } TEST(hive, SpliceProperties) @@ -2719,32 +2515,6 @@ TEST(hive, PmrCorrectness) he.insert(100, 42); hf.insert(100, 42); -#if !SG14_HIVE_P2596 - Hive h3(sg14::hive_limits(10, 10), &mr); - Hive h5(100, {10, 10}, &mr); - Hive h6(100, sg14::hive_limits(10, 10), &mr); - Hive h8(100, 42, {10, 10}, &mr); - Hive h9(100, 42, sg14::hive_limits(10, 10), &mr); - Hive hc({1, 2, 3, 4}, {10, 10}, &mr); - Hive hd({1, 2, 3, 4}, sg14::hive_limits(10, 10), &mr); - - EXPECT_EQ(h3.size(), 0u); - EXPECT_EQ(h5.size(), 100u); - EXPECT_EQ(h6.size(), 100u); - EXPECT_EQ(h8.size(), 100u); - EXPECT_EQ(h9.size(), 100u); - EXPECT_EQ(hc.size(), 4u); - EXPECT_EQ(hd.size(), 4u); - - h3.insert(100, 42); - h5.insert(100, 42); - h6.insert(100, 42); - h8.insert(100, 42); - h9.insert(100, 42); - hc.insert(100, 42); - hd.insert(100, 42); -#endif - #if __cpp_lib_ranges_to_container >= 202202L Hive hg(std::from_range, a, &mr); Hive hh(std::from_range, a | std::views::take(2), &mr); @@ -2761,11 +2531,7 @@ TEST(hive, PmrCorrectReshape) { sg14::hive> h(10); PmrGuard guard; -#if SG14_HIVE_P2596 h.reshape(400); -#else - h.reshape({4, 4}); -#endif EXPECT_EQ(h.size(), 10u); EXPECT_INVARIANTS(h); } @@ -2774,12 +2540,7 @@ TEST(hive, PmrCorrectShrinkToFit) { sg14::hive> h(10); PmrGuard guard; -#if SG14_HIVE_P2596 h.reshape(400); -#else - h.reshape({4, 4}); - h.reshape({3, 10}); -#endif h.shrink_to_fit(); EXPECT_EQ(h.size(), 10u); EXPECT_INVARIANTS(h);