]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/containers/sequences/vector/vector.special/db_swap_1.pass.cpp
Vendor import of libc++ release_39 branch r276489:
[FreeBSD/FreeBSD.git] / test / std / containers / sequences / vector / vector.special / db_swap_1.pass.cpp
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
12 // template <class T, class Alloc>
13 //   void swap(vector<T,Alloc>& x, vector<T,Alloc>& y);
14
15 #if _LIBCPP_DEBUG >= 1
16 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
17 #endif
18
19 #include <vector>
20 #include <cassert>
21
22 #include "min_allocator.h"
23
24 int main()
25 {
26 #if _LIBCPP_DEBUG >= 1
27     {
28         int a1[] = {1, 3, 7, 9, 10};
29         int a2[] = {0, 2, 4, 5, 6, 8, 11};
30         std::vector<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
31         std::vector<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
32         std::vector<int>::iterator i1 = c1.begin();
33         std::vector<int>::iterator i2 = c2.begin();
34         swap(c1, c2);
35         c1.erase(i2);
36         c2.erase(i1);
37         c1.erase(i1);
38         assert(false);
39     }
40 #if TEST_STD_VER >= 11
41     {
42         int a1[] = {1, 3, 7, 9, 10};
43         int a2[] = {0, 2, 4, 5, 6, 8, 11};
44         std::vector<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
45         std::vector<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
46         std::vector<int, min_allocator<int>>::iterator i1 = c1.begin();
47         std::vector<int, min_allocator<int>>::iterator i2 = c2.begin();
48         swap(c1, c2);
49         c1.erase(i2);
50         c2.erase(i1);
51         c1.erase(i1);
52         assert(false);
53     }
54 #endif
55 #endif
56 }