//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++03 // // list(list&& c); #include #include #include "test_macros.h" #include "MoveOnly.h" #include "test_allocator.h" #include "min_allocator.h" int main(int, char**) { { std::list > l(test_allocator(5)); std::list > lo(test_allocator(5)); for (int i = 1; i <= 3; ++i) { l.push_back(i); lo.push_back(i); } std::list >::iterator it = l.begin(); std::list > l2 = std::move(l); assert(l2 == lo); assert(l.empty()); assert(l2.get_allocator() == lo.get_allocator()); assert(it == l2.begin()); // Iterators remain valid } { std::list > l(other_allocator(5)); std::list > lo(other_allocator(5)); for (int i = 1; i <= 3; ++i) { l.push_back(i); lo.push_back(i); } std::list >::iterator it = l.begin(); std::list > l2 = std::move(l); assert(l2 == lo); assert(l.empty()); assert(l2.get_allocator() == lo.get_allocator()); assert(it == l2.begin()); // Iterators remain valid } { std::list > l(min_allocator{}); std::list > lo(min_allocator{}); for (int i = 1; i <= 3; ++i) { l.push_back(i); lo.push_back(i); } std::list >::iterator it = l.begin(); std::list > l2 = std::move(l); assert(l2 == lo); assert(l.empty()); assert(l2.get_allocator() == lo.get_allocator()); assert(it == l2.begin()); // Iterators remain valid } return 0; }