From 1bb99466bcfa188bca00855f80bd6098b0882419 Mon Sep 17 00:00:00 2001 From: couriersud Date: Thu, 24 Sep 2020 07:53:11 +0200 Subject: netlist: code refactoring * use default move and copy constructors * various minor edits like adding noexcept * removed a lot of inline keywords - you can't beat the compiler --- src/lib/netlist/plib/plists.h | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) (limited to 'src/lib/netlist/plib/plists.h') diff --git a/src/lib/netlist/plib/plists.h b/src/lib/netlist/plib/plists.h index 328f0b1ad23..19c34717126 100755 --- a/src/lib/netlist/plib/plists.h +++ b/src/lib/netlist/plib/plists.h @@ -172,7 +172,7 @@ namespace plib { /// \brief a simple linked list. /// - /// The list allows insertions deletions whilst being processed. + /// The list allows insertions and deletions whilst being processed. /// template class linkedlist_t @@ -187,10 +187,10 @@ namespace plib { constexpr element_t() : m_next(nullptr), m_prev(nullptr) {} ~element_t() noexcept = default; - PCOPYASSIGNMOVE(element_t, delete) + PCOPYASSIGNMOVE(element_t, default) - constexpr LC *next() const noexcept { return m_next; } - constexpr LC *prev() const noexcept { return m_prev; } + constexpr LC * &next() noexcept { return m_next; } + constexpr LC * &prev() noexcept { return m_prev; } private: LC * m_next; LC * m_prev; @@ -202,22 +202,14 @@ namespace plib { LC* p; public: explicit constexpr iter_t(LC* x) noexcept : p(x) { } - constexpr iter_t(iter_t &rhs) noexcept : p(rhs.p) { } - iter_t(iter_t &&rhs) noexcept { std::swap(*this, rhs); } + constexpr iter_t(const iter_t &rhs) noexcept = default; + iter_t(iter_t &&rhs) noexcept = default; - iter_t& operator=(const iter_t &rhs) noexcept // NOLINT(bugprone-unhandled-self-assignment, cert-oop54-cpp) - { - if (this == &rhs) - return *this; - - p = rhs.p; - return *this; - } - - iter_t& operator=(iter_t &&rhs) noexcept { std::swap(*this, rhs); return *this; } - ~iter_t() = default; + iter_t& operator=(const iter_t &rhs) noexcept = default; + iter_t& operator=(iter_t &&rhs) noexcept = default; + ~iter_t() noexcept = default; - iter_t& operator++() noexcept { p = p->next();return *this; } + iter_t& operator++() noexcept { p = p->next(); return *this; } // NOLINTNEXTLINE(cert-dcl21-cpp) iter_t operator++(int) & noexcept { const iter_t tmp(*this); operator++(); return tmp; } -- cgit v1.2.3-70-g09d2