diff --git a/src/include/containers/List.hpp b/src/include/containers/List.hpp index 6046502e3f..543b64d89b 100644 --- a/src/include/containers/List.hpp +++ b/src/include/containers/List.hpp @@ -43,45 +43,43 @@ template class __EXPORT ListNode { public: - ListNode() : _sibling(nullptr) - { - } - virtual ~ListNode() {}; + ListNode() : _sibling() {} + virtual ~ListNode() = default; + + // no copy, assignment, move, move assignment + ListNode(const ListNode &) = delete; + ListNode &operator=(const ListNode &) = delete; + ListNode(ListNode &&) = delete; + ListNode &operator=(ListNode &&) = delete; + void setSibling(T sibling) { _sibling = sibling; } - T getSibling() { return _sibling; } - T get() - { - return _sibling; - } + const T getSibling() { return _sibling; } + protected: T _sibling; -private: - // forbid copy - ListNode(const ListNode &other); - // forbid assignment - ListNode &operator = (const ListNode &); }; template class __EXPORT List { public: - List() : _head() - { - } - virtual ~List() {}; + List() : _head() {} + virtual ~List() = default; + + // no copy, assignment, move, move assignment + List(const List &) = delete; + List &operator=(const List &) = delete; + List(List &&) = delete; + List &operator=(List &&) = delete; + void add(T newNode) { newNode->setSibling(getHead()); - setHead(newNode); + _head = newNode; } - T getHead() { return _head; } + + const T getHead() { return _head; } + protected: - void setHead(T &head) { _head = head; } T _head; -private: - // forbid copy - List(const List &other); - // forbid assignment - List &operator = (const List &); };