Skip to content

Commit

Permalink
We still need to manually call the destructor on the moved object aft…
Browse files Browse the repository at this point in the history
…er moving
  • Loading branch information
redorav committed Sep 8, 2024
1 parent a71a8da commit 597fa4d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion include/crstl/open_hashtable_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ namespace crstl
node_type* const data = m_data;
node_type* const end_node = data + bucket_count;

// Destroy the current node
// Destroy the node we pass in
crstl_constexpr_if(!crstl_is_trivially_destructible(key_value_type))
{
node_to_erase->key_value.~key_value_type();
Expand Down Expand Up @@ -576,6 +576,13 @@ namespace crstl
if (can_move_node)
{
crstl_placement_new((void*)&(empty_slot->key_value)) key_value_type(crstl_move(node_to_move->key_value));

// Note that we still need to call the destructor here for moved types
crstl_constexpr_if(!crstl_is_trivially_destructible(key_value_type))
{
node_to_move->key_value.~key_value_type();
}

empty_slot = node_to_move;
}
}
Expand Down

0 comments on commit 597fa4d

Please sign in to comment.