@@ -606,7 +606,7 @@ namespace hud
606606 // To satisfy the compiler, allocate controls and slots in two separate allocations
607607 usize control_size {allocate_control_and_slot (max_slot_count_)};
608608
609- // If constant evaluated context
609+ // If constant evaluated context or when slot_type is not bitwise copy constructible
610610 // loop through all slot and construct them regardless of the trivially constructible ( Maybe only for control_ptr_ ) like like grow_capacity
611611 // In a non constant evaluated context
612612 // If type is trivially copy constructible, just memcpy control and slot
@@ -654,9 +654,17 @@ namespace hud
654654 return ;
655655
656656 free_slot_before_grow_ = max_slot_before_grow (max_slot_count_) - count_;
657+ // Allocate the buffer that will contain controls and aligned slots
658+ // In a constant-evaluated context, bit_cast cannot be used with pointers
659+ // To satisfy the compiler, allocate controls and slots in two separate allocations
657660 usize control_size {allocate_control_and_slot (max_slot_count_)};
658661
659- if (hud::is_constant_evaluated () || !hud::is_bitwise_copy_constructible_v<slot_type>)
662+ // If constant evaluated context or when slot_type is not bitwise copy constructible or when we allocate more memory than the copied set
663+ // loop through all slot and construct them regardless of the trivially constructible ( Maybe only for control_ptr_ ) like like grow_capacity
664+ // In a non constant evaluated context
665+ // If type is trivially copy constructible, just memcpy control and slot
666+ // else do like grow_capacity
667+ if (extra_max_count > 0 || hud::is_constant_evaluated () || !hud::is_bitwise_copy_constructible_v<slot_type>)
660668 {
661669 // Set control to empty ending with sentinel
662670 hud::memory::set (control_ptr_, control_size, empty_byte);
@@ -1162,7 +1170,7 @@ namespace hud
11621170 /* * The allocator. */
11631171 allocator_type allocator_;
11641172
1165- /* * The control of the hashmap. */
1173+ /* * The control of the hashmap. Initialized to sentinel. */
11661174 control_type *control_ptr_ {const_cast <control_type *>(&INIT_GROUP[16 ])};
11671175
11681176 /* * Pointer to the slot segment. */
0 commit comments