Fix flat_list: destructor hack should only compile for types with nontrivial destructor
This commit is contained in:
parent
76c465903b
commit
8ea508ee20
1 changed files with 20 additions and 18 deletions
|
|
@ -169,29 +169,31 @@ namespace psemek::util
|
|||
first_ = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (size_ == 0)
|
||||
else
|
||||
{
|
||||
if (size_ == 0)
|
||||
{
|
||||
nodes_.reset();
|
||||
capacity_ = 0;
|
||||
first_ = null;
|
||||
return;
|
||||
}
|
||||
|
||||
for (Handle h = first_; h != null;)
|
||||
{
|
||||
auto next = nodes_[h].next;
|
||||
new (&nodes_[h].value) T;
|
||||
h = next;
|
||||
}
|
||||
|
||||
for (std::size_t i = 0; i < capacity_; ++i)
|
||||
nodes_[i].value.~T();
|
||||
|
||||
nodes_.reset();
|
||||
capacity_ = 0;
|
||||
size_ = 0;
|
||||
first_ = null;
|
||||
return;
|
||||
}
|
||||
|
||||
for (Handle h = first_; h != null;)
|
||||
{
|
||||
auto next = nodes_[h].next;
|
||||
new (&nodes_[h].value) T;
|
||||
h = next;
|
||||
}
|
||||
|
||||
for (std::size_t i = 0; i < capacity_; ++i)
|
||||
nodes_[i].value.~T();
|
||||
|
||||
nodes_.reset();
|
||||
capacity_ = 0;
|
||||
size_ = 0;
|
||||
first_ = null;
|
||||
}
|
||||
|
||||
template <typename T, typename Handle>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue