C
ciccio
Hi,
I was wondering if std::vector stores its content in a sequential array?
Assume you reserve an std::vector for n places, but you push_back n+m
elements, what happens then?
As far as I know, the mechanism of std::vector will allocate n more
places and stores those m elements in there. But are they continuously
with the first n elements? I.e can I for example ask a pointer to the
first element in the vector and use pointer arithmetic to get to all the
elements in the vector, or are all the blocks extra allocated in
separate memory blocks?
I was wondering if std::vector stores its content in a sequential array?
Assume you reserve an std::vector for n places, but you push_back n+m
elements, what happens then?
As far as I know, the mechanism of std::vector will allocate n more
places and stores those m elements in there. But are they continuously
with the first n elements? I.e can I for example ask a pointer to the
first element in the vector and use pointer arithmetic to get to all the
elements in the vector, or are all the blocks extra allocated in
separate memory blocks?