blob: 575e1658276b6d6cf43ccc1805a31704c3880825 [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnantf5256e12010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// <list>
11
12// list(list&& c, const allocator_type& a);
13
14#include <list>
15#include <cassert>
16#include "../../../MoveOnly.h"
17#include "../../../test_allocator.h"
18
19int main()
20{
Howard Hinnant73d21a42010-09-04 23:28:19 +000021#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000022 {
23 std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
24 std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
25 for (int i = 1; i <= 3; ++i)
26 {
27 l.push_back(i);
28 lo.push_back(i);
29 }
30 std::list<MoveOnly, test_allocator<MoveOnly> > l2(std::move(l), test_allocator<MoveOnly>(6));
31 assert(l2 == lo);
32 assert(!l.empty());
33 assert(l2.get_allocator() == test_allocator<MoveOnly>(6));
34 }
35 {
36 std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
37 std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
38 for (int i = 1; i <= 3; ++i)
39 {
40 l.push_back(i);
41 lo.push_back(i);
42 }
43 std::list<MoveOnly, test_allocator<MoveOnly> > l2(std::move(l), test_allocator<MoveOnly>(5));
44 assert(l2 == lo);
45 assert(l.empty());
46 assert(l2.get_allocator() == test_allocator<MoveOnly>(5));
47 }
48 {
49 std::list<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
50 std::list<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
51 for (int i = 1; i <= 3; ++i)
52 {
53 l.push_back(i);
54 lo.push_back(i);
55 }
56 std::list<MoveOnly, other_allocator<MoveOnly> > l2(std::move(l), other_allocator<MoveOnly>(4));
57 assert(l2 == lo);
58 assert(!l.empty());
59 assert(l2.get_allocator() == other_allocator<MoveOnly>(4));
60 }
Howard Hinnant73d21a42010-09-04 23:28:19 +000061#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000062}