blob: f7171795cd5f0e30c7d5ce9a87743cf1bebe04f8 [file] [log] [blame]
Howard Hinnant6dcaf3e2013-04-05 17:58:52 +00001//===----------------------------------------------------------------------===//
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// <list>
11
12// template <class T, class Alloc>
13// void swap(list<T,Alloc>& x, list<T,Alloc>& y);
14
Howard Hinnant5e571422013-08-23 20:10:18 +000015#if _LIBCPP_DEBUG >= 1
Howard Hinnant6dcaf3e2013-04-05 17:58:52 +000016#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
17#endif
18
19#include <list>
20#include <cassert>
21
22#include <__debug>
Marshall Clow061d0cc2013-11-26 20:58:02 +000023#include "min_allocator.h"
Howard Hinnant6dcaf3e2013-04-05 17:58:52 +000024
25int main()
26{
Howard Hinnant5e571422013-08-23 20:10:18 +000027#if _LIBCPP_DEBUG >= 1
Howard Hinnant6dcaf3e2013-04-05 17:58:52 +000028 {
29 int a1[] = {1, 3, 7, 9, 10};
30 int a2[] = {0, 2, 4, 5, 6, 8, 11};
31 std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
32 std::list<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
33 std::list<int>::iterator i1 = c1.begin();
34 std::list<int>::iterator i2 = c2.begin();
35 swap(c1, c2);
36 c1.erase(i2);
37 c2.erase(i1);
38 std::list<int>::iterator j = i1;
39 c1.erase(i1);
40 assert(false);
41 }
Howard Hinnant29f74322013-06-25 16:08:47 +000042#if __cplusplus >= 201103L
43 {
44 int a1[] = {1, 3, 7, 9, 10};
45 int a2[] = {0, 2, 4, 5, 6, 8, 11};
46 std::list<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
47 std::list<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
48 std::list<int, min_allocator<int>>::iterator i1 = c1.begin();
49 std::list<int, min_allocator<int>>::iterator i2 = c2.begin();
50 swap(c1, c2);
51 c1.erase(i2);
52 c2.erase(i1);
53 std::list<int, min_allocator<int>>::iterator j = i1;
54 c1.erase(i1);
55 assert(false);
56 }
57#endif
Howard Hinnant6dcaf3e2013-04-05 17:58:52 +000058#endif
59}