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 
     12 // class vector
     13 
     14 // size_type size() const noexcept;
     15 
     16 #include <vector>
     17 #include <cassert>
     18 
     19 #include "test_macros.h"
     20 #include "min_allocator.h"
     21 
     22 int main()
     23 {
     24     {
     25     typedef std::vector<bool> C;
     26     C c;
     27     ASSERT_NOEXCEPT(c.size());
     28     assert(c.size() == 0);
     29     c.push_back(false);
     30     assert(c.size() == 1);
     31     c.push_back(true);
     32     assert(c.size() == 2);
     33     c.push_back(false);
     34     assert(c.size() == 3);
     35     c.erase(c.begin());
     36     assert(c.size() == 2);
     37     c.erase(c.begin());
     38     assert(c.size() == 1);
     39     c.erase(c.begin());
     40     assert(c.size() == 0);
     41     }
     42 #if TEST_STD_VER >= 11
     43     {
     44     typedef std::vector<bool, min_allocator<bool>> C;
     45     C c;
     46     ASSERT_NOEXCEPT(c.size());
     47     assert(c.size() == 0);
     48     c.push_back(false);
     49     assert(c.size() == 1);
     50     c.push_back(true);
     51     assert(c.size() == 2);
     52     c.push_back(false);
     53     assert(c.size() == 3);
     54     c.erase(c.begin());
     55     assert(c.size() == 2);
     56     c.erase(c.begin());
     57     assert(c.size() == 1);
     58     c.erase(c.begin());
     59     assert(c.size() == 0);
     60     }
     61 #endif
     62 }
     63