wilhelmtell / reserve

Create a vector with reserved capacity

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

 reserve - create a vector with reserved capacity


 WHY?

 i'onno.


 EXAMPLE

 #include <vector>
 #include <iostream>
 #include "reserve.hh"

 int main(int, char*[]) {
   std::vector<int> const vi(rsv::reserve(100));
   auto const vc = std::vector<char>(rsv::reserve(140));
   std::cout << "capacity >= 100: " << vi.capacity() << '\n';
   std::cout << "capacity >= 140: " << vc.capacity() << '\n';
 }

About

Create a vector with reserved capacity


Languages

Language:C++ 58.2%Language:CMake 41.8%