From 2409d46d4c165a9bac7cb69547a88c3a546994c5 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Wed, 10 Jan 2018 23:58:36 -0500 Subject: [PATCH] Prohibit copy of TrackList, no longer needed; allow swap and move --- src/Track.cpp | 27 --------------------------- src/Track.h | 15 ++++++--------- 2 files changed, 6 insertions(+), 36 deletions(-) diff --git a/src/Track.cpp b/src/Track.cpp index 8e387d011..a65da94b8 100644 --- a/src/Track.cpp +++ b/src/Track.cpp @@ -792,15 +792,6 @@ std::shared_ptr TrackList::Create() return result; } -TrackList& TrackList::operator= (const TrackList &that) -{ - if (this != &that) { - this->Clear(); - DoAssign(that); - } - return *this; -} - TrackList &TrackList::operator= (TrackList &&that) { if (this != &that) { @@ -810,24 +801,6 @@ TrackList &TrackList::operator= (TrackList &&that) return *this; } -void TrackList::DoAssign(const TrackList &that) -{ - auto copyLOT = []( - ListOfTracks &dst, const std::weak_ptr< TrackList > &self, - const ListOfTracks &src ) - { - for (const auto &ptr : src) - dst.push_back( - ListOfTracks::value_type{ ptr->Duplicate().release() } ); - for (auto it = dst.begin(), last = dst.end(); it != last; ++it) - (*it)->SetOwner(self, it); - }; - copyLOT( *this, mSelf, that ); - copyLOT( this->mPendingAdditions, mSelf, that.mPendingAdditions ); - copyLOT( this->mPendingUpdates, mSelf, that.mPendingUpdates ); - mUpdaters = that.mUpdaters; -} - void TrackList::Swap(TrackList &that) { auto SwapLOTs = []( diff --git a/src/Track.h b/src/Track.h index 89842228e..0c5d5c7d1 100644 --- a/src/Track.h +++ b/src/Track.h @@ -659,8 +659,13 @@ class TrackList final : public wxEvtHandler, public ListOfTracks // Create an empty TrackList TrackList(); + // Disallow copy TrackList(const TrackList &that) = delete; - TrackList(TrackList &&that) = delete; + TrackList &operator= (const TrackList&) = delete; + + // Allow move + TrackList(TrackList &&that) : TrackList() { Swap(that); } + TrackList& operator= (TrackList&&); void clear() = delete; @@ -668,12 +673,6 @@ class TrackList final : public wxEvtHandler, public ListOfTracks // Create an empty TrackList static std::shared_ptr Create(); - // Allow copy -- a deep copy that duplicates all tracks - TrackList &operator= (const TrackList &that); - - // Allow move - TrackList& operator= (TrackList&&); - // Move is defined in terms of Swap void Swap(TrackList &that); @@ -831,8 +830,6 @@ private: } } - void DoAssign(const TrackList &that); - void RecalcPositions(TrackNodePointer node); void PermutationEvent(); void DeletionEvent();