How do you do it?
by Jonathan Boccara
From the article:
Inserting elements in a vector sounds like the most basic use case we can think of when it comes to using collections in C++.
Nevertheless, this is a complex topic in itself, because std::vector offers various ways to insert several elements. Choosing the most appropriate depending on your exact use case allows to write more expressive code. And misusing the interface of std::vector can lead to memory errors.
Let’s navigate the various ways to insert several elements in a vector in a safe way, so that you can choose the one that fits best for your code...