The – suboptimal – way to inserting several elements by using , just as if we were discovering each time that there was yet another element to append.
This potentially causes multiple reallocations of the vector.
This really ties in with a similar guideline we saw when searching into a container with the STL.
In the previous lesson, we introduced std::array, which provides the functionality of C ’s built-in fixed arrays in a safer and more usable form.
A couple of weeks ago, I had the chance to hear some feedback from Stephan T.
Lavavej about the STL learning resource on Fluent C .
It concerns how to insert several elements into a container.
In the posts concerning the STL, I use output iterators such as quite intensely.
std::vector lives in the Note that in both the uninitialized and initialized case, you do not need to include the array length at compile time.
This is because std::vector will dynamically allocate memory for its contents as requested.