diff --git a/src/kernel/templates/SkipList.hpp b/src/kernel/templates/SkipList.hpp index cf893f944..17bb6849f 100644 --- a/src/kernel/templates/SkipList.hpp +++ b/src/kernel/templates/SkipList.hpp @@ -24,23 +24,18 @@ protected: Node *before = nullptr; bool end = false; - alignas(Data) std::array data; - Data &get() { assert(!end); - return *std::launder(reinterpret_cast(&data[0])); + return *std::launder(reinterpret_cast(&_data[0])); } const Data &get() const { assert(!end); - return *std::launder(reinterpret_cast(&data[0])); + return *std::launder(reinterpret_cast(&_data[0])); } - }; - // static_assert(std::is_trivially_constructible::value); - // static_assert(std::is_trivially_destructible::value); - // static_assert(std::is_trivially_copyable::value); - // static_assert(std::is_trivially_move_assignable::value); - // static_assert(std::is_trivially_move_constructible::value); + private: + alignas(Data) std::array _data; + }; class NodeAllocator { static constexpr int size{64}; @@ -138,8 +133,8 @@ public: curL = newLevel; } - auto newNode = (Node *) nodeAllocator.get(); - newNode->data = n->data; + auto newNode = (Node *) nodeAllocator.get(); + new (&newNode->get()) Data(n->get()); newNode->before = toUpdate[0]; if (toUpdate[0]->next[0] != nullptr) toUpdate[0]->next[0]->before = newNode;