1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // UNSUPPORTED: c++98, c++03
10 
11 // <list>
12 
13 // list(list&& c);
14 
15 #include <list>
16 #include <cassert>
17 #include "MoveOnly.h"
18 #include "test_allocator.h"
19 #include "min_allocator.h"
20 
21 int main(int, char**)
22 {
23     {
24         std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
25         std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
26         for (int i = 1; i <= 3; ++i)
27         {
28             l.push_back(i);
29             lo.push_back(i);
30         }
31         std::list<MoveOnly, test_allocator<MoveOnly> > l2 = std::move(l);
32         assert(l2 == lo);
33         assert(l.empty());
34         assert(l2.get_allocator() == lo.get_allocator());
35     }
36     {
37         std::list<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
38         std::list<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
39         for (int i = 1; i <= 3; ++i)
40         {
41             l.push_back(i);
42             lo.push_back(i);
43         }
44         std::list<MoveOnly, other_allocator<MoveOnly> > l2 = std::move(l);
45         assert(l2 == lo);
46         assert(l.empty());
47         assert(l2.get_allocator() == lo.get_allocator());
48     }
49     {
50         std::list<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
51         std::list<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
52         for (int i = 1; i <= 3; ++i)
53         {
54             l.push_back(i);
55             lo.push_back(i);
56         }
57         std::list<MoveOnly, min_allocator<MoveOnly> > l2 = std::move(l);
58         assert(l2 == lo);
59         assert(l.empty());
60         assert(l2.get_allocator() == lo.get_allocator());
61     }
62 
63   return 0;
64 }
65