mirror of
https://github.com/usatiuk/ficus.git
synced 2025-10-29 00:27:52 +01:00
Fix skip list copy not calling copy constructor for elements
This commit is contained in:
@@ -24,23 +24,18 @@ protected:
|
|||||||
Node *before = nullptr;
|
Node *before = nullptr;
|
||||||
bool end = false;
|
bool end = false;
|
||||||
|
|
||||||
alignas(Data) std::array<unsigned char, sizeof(Data)> data;
|
|
||||||
|
|
||||||
Data &get() {
|
Data &get() {
|
||||||
assert(!end);
|
assert(!end);
|
||||||
return *std::launder(reinterpret_cast<Data *>(&data[0]));
|
return *std::launder(reinterpret_cast<Data *>(&_data[0]));
|
||||||
}
|
}
|
||||||
const Data &get() const {
|
const Data &get() const {
|
||||||
assert(!end);
|
assert(!end);
|
||||||
return *std::launder(reinterpret_cast<const Data *>(&data[0]));
|
return *std::launder(reinterpret_cast<const Data *>(&_data[0]));
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
// static_assert(std::is_trivially_constructible<Node>::value);
|
private:
|
||||||
// static_assert(std::is_trivially_destructible<Node>::value);
|
alignas(Data) std::array<unsigned char, sizeof(Data)> _data;
|
||||||
// static_assert(std::is_trivially_copyable<Node>::value);
|
};
|
||||||
// static_assert(std::is_trivially_move_assignable<Node>::value);
|
|
||||||
// static_assert(std::is_trivially_move_constructible<Node>::value);
|
|
||||||
|
|
||||||
class NodeAllocator {
|
class NodeAllocator {
|
||||||
static constexpr int size{64};
|
static constexpr int size{64};
|
||||||
@@ -138,8 +133,8 @@ public:
|
|||||||
curL = newLevel;
|
curL = newLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto newNode = (Node *) nodeAllocator.get();
|
auto newNode = (Node *) nodeAllocator.get();
|
||||||
newNode->data = n->data;
|
new (&newNode->get()) Data(n->get());
|
||||||
newNode->before = toUpdate[0];
|
newNode->before = toUpdate[0];
|
||||||
if (toUpdate[0]->next[0] != nullptr) toUpdate[0]->next[0]->before = newNode;
|
if (toUpdate[0]->next[0] != nullptr) toUpdate[0]->next[0]->before = newNode;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user