File tree Expand file tree Collapse file tree 2 files changed +37
-6
lines changed
include/fast_io_dsal/impl
tests/0026.container/0002.list Expand file tree Collapse file tree 2 files changed +37
-6
lines changed Original file line number Diff line number Diff line change @@ -907,15 +907,19 @@ class list
907907 }
908908
909909 inline constexpr list (list &&other) noexcept
910- : imp(other.imp)
911910 #if 0
912- , allochdl(std::move(other.allochdl))
911+ : allochdl(std::move(other.allochdl))
913912 #endif
914913 {
915- auto prev = static_cast <::fast_io::containers::details::list_node_common *>(imp.prev );
916- auto next = static_cast <::fast_io::containers::details::list_node_common *>(imp.next );
917- next->prev = prev->next = __builtin_addressof (imp);
918- other.imp = {__builtin_addressof (other.imp ), __builtin_addressof (other.imp )};
914+ if (other.empty ()) {
915+ imp = {__builtin_addressof (imp), __builtin_addressof (imp)};
916+ } else {
917+ imp = other.imp ;
918+ auto prev = static_cast <::fast_io::containers::details::list_node_common *>(imp.prev );
919+ auto next = static_cast <::fast_io::containers::details::list_node_common *>(imp.next );
920+ next->prev = prev->next = __builtin_addressof (imp);
921+ other.imp = {__builtin_addressof (other.imp ), __builtin_addressof (other.imp )};
922+ }
919923 }
920924
921925 inline constexpr list &operator =(list &&other) noexcept
Original file line number Diff line number Diff line change 1+
2+ #include < fast_io_dsal/list.h>
3+
4+ int main () {
5+ ::fast_io::list<int > l1{};
6+ if (!l1.empty ()) {
7+ ::fast_io::fast_terminate ();
8+ }
9+
10+ ::fast_io::list<int > l2 (::std::move (l1));
11+ if (!l2.empty ()) {
12+ ::fast_io::fast_terminate ();
13+ }
14+
15+ ::fast_io::list<int > l3{};
16+ l3.emplace_back (1 );
17+ if (l3.empty ()) {
18+ ::fast_io::fast_terminate ();
19+ }
20+
21+ ::fast_io::list<int > l4 (::std::move (l3));
22+ if (l4.empty ()) {
23+ ::fast_io::fast_terminate ();
24+ }
25+
26+ return 0 ;
27+ }
You can’t perform that action at this time.
0 commit comments