libcxx

libcxx mirror with random patches
git clone https://git.neptards.moe/neptards/libcxx.git
Log | Files | Refs

shrink_to_fit.pass.cpp (878B)


      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 // void shrink_to_fit();
     14 
     15 #include <vector>
     16 #include <cassert>
     17 
     18 #include "min_allocator.h"
     19 
     20 int main()
     21 {
     22     {
     23         std::vector<bool> v(100);
     24         v.push_back(1);
     25         v.shrink_to_fit();
     26         assert(v.capacity() >= 101);
     27         assert(v.size() >= 101);
     28     }
     29 #if TEST_STD_VER >= 11
     30     {
     31         std::vector<bool, min_allocator<bool>> v(100);
     32         v.push_back(1);
     33         v.shrink_to_fit();
     34         assert(v.capacity() >= 101);
     35         assert(v.size() >= 101);
     36     }
     37 #endif
     38 }