Home | History | Annotate | Download | only in list.special
      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 
     15 #if _LIBCPP_DEBUG >= 1
     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>
     23 #include "min_allocator.h"
     24 
     25 int main()
     26 {
     27 #if _LIBCPP_DEBUG >= 1
     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     }
     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
     58 #endif
     59 }
     60