What is capacity() for std::vector , which is created using the standard constuctor? I know that size() is zero. Can we state that the default vector does not cause heap memory allocation?
Thus, it is possible to create an array with an arbitrary reserve using one selection, for example std::vector<int> iv; iv.reserve(2345); std::vector<int> iv; iv.reserve(2345); . Let's say that for some reason I don't want to run size() on 2345.
For example, on Linux (g ++ 4.4.5, kernel 2.6.32 amd64)
#include <iostream> #include <vector> int main() { using namespace std; cout << vector<int>().capacity() << "," << vector<int>(10).capacity() << endl; return 0; }
printed 0,10 . Is this a rule, or does it depend on the STL provider?
c ++ memory-management vector stl
Notinlist Sep 04 2018-12-12T00: 00Z
source share