I thought of this problem due to some of the answers I got to the following problem suggesting that I could use vector<T>::assign
or copy
with a back_insert_iterator
here. My problem is, what are the drawbacks and advantages of using one method over another?
assign
overwrites the content of the vector
where as copy
with back_insert_iterator
does a push_back
on the vector thus preseving its content.
EDIT: If the question is generic (i.e. whether to use a member function defined in the container or an algorithm), I prefer to use the member function as it might have been optimized for the particular container compared to a generic algorithm.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With