Home | History | Annotate | Download | only in vector.bool
      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 // iterator erase(const_iterator position);
     14 
     15 #include <vector>
     16 #include <cassert>
     17 
     18 #include "min_allocator.h"
     19 
     20 int main()
     21 {
     22     bool a1[] = {1, 0, 1};
     23     {
     24     std::vector<bool> l1(a1, a1+3);
     25     std::vector<bool>::const_iterator i = l1.begin();
     26     ++i;
     27     std::vector<bool>::iterator j = l1.erase(i);
     28     assert(l1.size() == 2);
     29     assert(distance(l1.begin(), l1.end()) == 2);
     30     assert(*j == true);
     31     assert(*l1.begin() == 1);
     32     assert(*next(l1.begin()) == true);
     33     j = l1.erase(j);
     34     assert(j == l1.end());
     35     assert(l1.size() == 1);
     36     assert(distance(l1.begin(), l1.end()) == 1);
     37     assert(*l1.begin() == true);
     38     j = l1.erase(l1.begin());
     39     assert(j == l1.end());
     40     assert(l1.size() == 0);
     41     assert(distance(l1.begin(), l1.end()) == 0);
     42     }
     43 #if __cplusplus >= 201103L
     44     {
     45     std::vector<bool, min_allocator<bool>> l1(a1, a1+3);
     46     std::vector<bool, min_allocator<bool>>::const_iterator i = l1.begin();
     47     ++i;
     48     std::vector<bool, min_allocator<bool>>::iterator j = l1.erase(i);
     49     assert(l1.size() == 2);
     50     assert(distance(l1.begin(), l1.end()) == 2);
     51     assert(*j == true);
     52     assert(*l1.begin() == 1);
     53     assert(*next(l1.begin()) == true);
     54     j = l1.erase(j);
     55     assert(j == l1.end());
     56     assert(l1.size() == 1);
     57     assert(distance(l1.begin(), l1.end()) == 1);
     58     assert(*l1.begin() == true);
     59     j = l1.erase(l1.begin());
     60     assert(j == l1.end());
     61     assert(l1.size() == 0);
     62     assert(distance(l1.begin(), l1.end()) == 0);
     63     }
     64 #endif
     65 }
     66