Just like std::array, accessing array elements can be done via the  operator (which does no bounds checking) or the at() function (which does bounds checking): In this case, the vector will self-resize to match number of elements provided.
Self-cleanup prevents memory leaks When a vector variable goes out of scope, it automatically deallocates the memory it controls (if necessary).
This may or may not be be overkill depending on whether this code is proven to be a performance bottleneck.
In conclusion, to insert several elements into a container, use the container methods whenever you can.
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.
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.