We said that algorithms do not change the size of the containers over which they operate. Why doesn’t the use of back_inserter invalidate this claim
belongs to book: C++ Primer|Stanley B.Lippman, Josee Lajoie, Barbara E.Moo|5th Edition| Chapter number:10| Question number:8
All Answers
total answers (1)
Because all the changes of the container size are made by the insert iterator, not the algorithm.
The algorithms may
- read elements,
- wirte elements (change the elements in the container),
- reorder elements (change the sequence of the elements in the container),
and the algorithms never
- add/remove elements (change the size of the container).