Home | History | Annotate | Download | only in vector.capacity
      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 // void resize(size_type sz);
     13 
     14 #include <vector>
     15 #include <cassert>
     16 #include "../../../stack_allocator.h"
     17 #include "../../../MoveOnly.h"
     18 
     19 int main()
     20 {
     21 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
     22     {
     23         std::vector<MoveOnly> v(100);
     24         v.resize(50);
     25         assert(v.size() == 50);
     26         assert(v.capacity() == 100);
     27         v.resize(200);
     28         assert(v.size() == 200);
     29         assert(v.capacity() >= 200);
     30     }
     31     {
     32         std::vector<MoveOnly, stack_allocator<MoveOnly, 300> > v(100);
     33         v.resize(50);
     34         assert(v.size() == 50);
     35         assert(v.capacity() == 100);
     36         v.resize(200);
     37         assert(v.size() == 200);
     38         assert(v.capacity() >= 200);
     39     }
     40 #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
     41     {
     42         std::vector<int> v(100);
     43         v.resize(50);
     44         assert(v.size() == 50);
     45         assert(v.capacity() == 100);
     46         v.resize(200);
     47         assert(v.size() == 200);
     48         assert(v.capacity() >= 200);
     49     }
     50     {
     51         std::vector<int, stack_allocator<int, 300> > v(100);
     52         v.resize(50);
     53         assert(v.size() == 50);
     54         assert(v.capacity() == 100);
     55         v.resize(200);
     56         assert(v.size() == 200);
     57         assert(v.capacity() >= 200);
     58     }
     59 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
     60 }
     61