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 // <vector>
11 // vector<bool>
12
13 // void swap(vector& x);
14
15 #include <vector>
16 #include <cassert>
17 #include "../../test_allocator.h"
18
main()19 int main()
20 {
21 {
22 std::vector<bool> v1(100);
23 std::vector<bool> v2(200);
24 v1.swap(v2);
25 assert(v1.size() == 200);
26 assert(v1.capacity() >= 200);
27 assert(v2.size() == 100);
28 assert(v2.capacity() >= 100);
29 }
30 {
31 typedef test_allocator<bool> A;
32 std::vector<bool, A> v1(100, true, A(1));
33 std::vector<bool, A> v2(200, false, A(2));
34 swap(v1, v2);
35 assert(v1.size() == 200);
36 assert(v1.capacity() >= 200);
37 assert(v2.size() == 100);
38 assert(v2.capacity() >= 100);
39 assert(v1.get_allocator() == A(1));
40 assert(v2.get_allocator() == A(2));
41 }
42 {
43 typedef other_allocator<bool> A;
44 std::vector<bool, A> v1(100, true, A(1));
45 std::vector<bool, A> v2(200, false, A(2));
46 swap(v1, v2);
47 assert(v1.size() == 200);
48 assert(v1.capacity() >= 200);
49 assert(v2.size() == 100);
50 assert(v2.capacity() >= 100);
51 assert(v1.get_allocator() == A(2));
52 assert(v2.get_allocator() == A(1));
53 }
54 }
55