diff --git a/src/common/intrusive_list.h b/src/common/intrusive_list.h index 09ff6a1a..08184381 100644 --- a/src/common/intrusive_list.h +++ b/src/common/intrusive_list.h @@ -23,7 +23,6 @@ template class IntrusiveListConstIterator; template class IntrusiveListNode { public: - IntrusiveListNode() : next(this), prev(this) {} void UnlinkFromList() { prev->next = next; next->prev = prev; @@ -31,12 +30,13 @@ public: next = prev = nullptr; #endif } + private: friend class IntrusiveList; friend class IntrusiveListIterator; friend class IntrusiveListConstIterator; - IntrusiveListNode* next; - IntrusiveListNode* prev; + IntrusiveListNode* next = this; + IntrusiveListNode* prev = this; }; template @@ -125,13 +125,11 @@ private: template class IntrusiveListIterator { public: - IntrusiveListIterator() : root(nullptr), node(nullptr) {} - IntrusiveListIterator(IntrusiveList* list, IntrusiveListNode* node) : root(list->root.get()), node(node) {} - IntrusiveListIterator(const IntrusiveListIterator& other) : root(other.root), node(other.node) {} - IntrusiveListIterator& operator=(IntrusiveListIterator other) { - std::swap(root, other.root); - std::swap(node, other.node); - return *this; + IntrusiveListIterator() = default; + IntrusiveListIterator(const IntrusiveListIterator& other) = default; + IntrusiveListIterator& operator=(const IntrusiveListIterator& other) = default; + + IntrusiveListIterator(IntrusiveList* list, IntrusiveListNode* node) : root(list->root.get()), node(node) { } IntrusiveListIterator& operator++() { @@ -180,20 +178,18 @@ public: private: friend class IntrusiveList; - IntrusiveListNode* root; - IntrusiveListNode* node; + IntrusiveListNode* root = nullptr; + IntrusiveListNode* node = nullptr; }; template class IntrusiveListConstIterator { public: - IntrusiveListConstIterator() : root(nullptr), node(nullptr) {} - IntrusiveListConstIterator(const IntrusiveList* list, IntrusiveListNode* node) : root(list->root.get()), node(node) {} - IntrusiveListConstIterator(const IntrusiveListConstIterator& other) : root(other.root), node(other.node) {} - IntrusiveListConstIterator& operator=(IntrusiveListConstIterator other) { - std::swap(root, other.root); - std::swap(node, other.node); - return *this; + IntrusiveListConstIterator() = default; + IntrusiveListConstIterator(const IntrusiveListConstIterator& other) = default; + IntrusiveListConstIterator& operator=(const IntrusiveListConstIterator& other) = default; + + IntrusiveListConstIterator(const IntrusiveList* list, IntrusiveListNode* node) : root(list->root.get()), node(node) { } IntrusiveListConstIterator& operator++() { @@ -234,8 +230,8 @@ public: private: friend class IntrusiveList; - IntrusiveListNode* root; - IntrusiveListNode* node; + IntrusiveListNode* root = nullptr; + IntrusiveListNode* node = nullptr; }; template