Howard Hinnant | 6dcaf3e | 2013-04-05 17:58:52 +0000 | [diff] [blame] | 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 | // <list> |
| 11 | |
| 12 | // template <class T, class Alloc> |
| 13 | // void swap(list<T,Alloc>& x, list<T,Alloc>& y); |
| 14 | |
Howard Hinnant | 5e57142 | 2013-08-23 20:10:18 +0000 | [diff] [blame] | 15 | #if _LIBCPP_DEBUG >= 1 |
Howard Hinnant | 6dcaf3e | 2013-04-05 17:58:52 +0000 | [diff] [blame] | 16 | #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 Clow | 061d0cc | 2013-11-26 20:58:02 +0000 | [diff] [blame] | 23 | #include "min_allocator.h" |
Howard Hinnant | 6dcaf3e | 2013-04-05 17:58:52 +0000 | [diff] [blame] | 24 | |
| 25 | int main() |
| 26 | { |
Howard Hinnant | 5e57142 | 2013-08-23 20:10:18 +0000 | [diff] [blame] | 27 | #if _LIBCPP_DEBUG >= 1 |
Howard Hinnant | 6dcaf3e | 2013-04-05 17:58:52 +0000 | [diff] [blame] | 28 | { |
| 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 Hinnant | 29f7432 | 2013-06-25 16:08:47 +0000 | [diff] [blame] | 42 | #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 Hinnant | 6dcaf3e | 2013-04-05 17:58:52 +0000 | [diff] [blame] | 58 | #endif |
| 59 | } |