blob: 83ea071b51c4541c034c3c234c70634c097e23b3 [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// <vector>
11
12// vector(vector&& c, const allocator_type& a);
13
14#include <vector>
15#include <cassert>
16#include "../../test_allocator.h"
17
18int main()
19{
Howard Hinnant73d21a42010-09-04 23:28:19 +000020#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000021 {
22 std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
23 std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5));
24 for (int i = 1; i <= 3; ++i)
25 {
26 l.push_back(i);
27 lo.push_back(i);
28 }
29 std::vector<bool, test_allocator<bool> > l2(std::move(l), test_allocator<bool>(6));
30 assert(l2 == lo);
31 assert(!l.empty());
32 assert(l2.get_allocator() == test_allocator<bool>(6));
33 }
34 {
35 std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
36 std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5));
37 for (int i = 1; i <= 3; ++i)
38 {
39 l.push_back(i);
40 lo.push_back(i);
41 }
42 std::vector<bool, test_allocator<bool> > l2(std::move(l), test_allocator<bool>(5));
43 assert(l2 == lo);
44 assert(l.empty());
45 assert(l2.get_allocator() == test_allocator<bool>(5));
46 }
47 {
48 std::vector<bool, other_allocator<bool> > l(other_allocator<bool>(5));
49 std::vector<bool, other_allocator<bool> > lo(other_allocator<bool>(5));
50 for (int i = 1; i <= 3; ++i)
51 {
52 l.push_back(i);
53 lo.push_back(i);
54 }
55 std::vector<bool, other_allocator<bool> > l2(std::move(l), other_allocator<bool>(4));
56 assert(l2 == lo);
57 assert(!l.empty());
58 assert(l2.get_allocator() == other_allocator<bool>(4));
59 }
Howard Hinnant73d21a42010-09-04 23:28:19 +000060#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000061}