Skip to content

Commit c57ee31

Browse files
committed
list: do not swap lists on move assignment
We somewhy swap lists instead of moving one to another in move assignment operator now. Let's fix it - simply reset list after it is moved. Part of #110
1 parent 8bb0481 commit c57ee31

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/Utils/List.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,8 @@ template <class Elem, class Tag>
473473
inline List<Elem, Tag>& List<Elem, Tag>::operator=(List&& list) noexcept
474474
{
475475
m_Ring.rgSwap(&list.m_Ring);
476+
list.m_Ring.rgRemove();
477+
list.m_Ring.rgInit();
476478
return *this;
477479
}
478480

test/ListUnitTest.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -881,11 +881,11 @@ void test_ctors()
881881
Object a(1, tmp_list);
882882
Object b(2, tmp_list, true);
883883
tmp_list = std::move(list);
884-
CHECK(list, { 1, 2 } );
884+
CHECK(list, {});
885885
CHECK(tmp_list, { } );
886886
Object e(5, list, true);
887887
Object f(6, tmp_list, true);
888-
CHECK(list, { 1, 2, 5 } );
888+
CHECK(list, {5});
889889
CHECK(tmp_list, { 6 } );
890890
}
891891

@@ -896,11 +896,11 @@ void test_ctors()
896896
Object c(3, tmp_list);
897897
Object d(4, tmp_list, true);
898898
tmp_list = std::move(list);
899-
CHECK(list, { 3, 4 } );
899+
CHECK(list, {});
900900
CHECK(tmp_list, { 1, 2 } );
901901
Object e(5, list, true);
902902
Object f(6, tmp_list, true);
903-
CHECK(list, { 3, 4, 5 } );
903+
CHECK(list, {5});
904904
CHECK(tmp_list, { 1, 2, 6 } );
905905
}
906906

0 commit comments

Comments
 (0)