• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // UNSUPPORTED: c++98, c++03
11 
12 // <list>
13 
14 // list(list&& c);
15 
16 #include <list>
17 #include <cassert>
18 #include "MoveOnly.h"
19 #include "test_allocator.h"
20 #include "min_allocator.h"
21 
main()22 int main()
23 {
24     {
25         std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
26         std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
27         for (int i = 1; i <= 3; ++i)
28         {
29             l.push_back(i);
30             lo.push_back(i);
31         }
32         std::list<MoveOnly, test_allocator<MoveOnly> > l2 = std::move(l);
33         assert(l2 == lo);
34         assert(l.empty());
35         assert(l2.get_allocator() == lo.get_allocator());
36     }
37     {
38         std::list<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
39         std::list<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
40         for (int i = 1; i <= 3; ++i)
41         {
42             l.push_back(i);
43             lo.push_back(i);
44         }
45         std::list<MoveOnly, other_allocator<MoveOnly> > l2 = std::move(l);
46         assert(l2 == lo);
47         assert(l.empty());
48         assert(l2.get_allocator() == lo.get_allocator());
49     }
50     {
51         std::list<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
52         std::list<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
53         for (int i = 1; i <= 3; ++i)
54         {
55             l.push_back(i);
56             lo.push_back(i);
57         }
58         std::list<MoveOnly, min_allocator<MoveOnly> > l2 = std::move(l);
59         assert(l2 == lo);
60         assert(l.empty());
61         assert(l2.get_allocator() == lo.get_allocator());
62     }
63 }
64