vendredi 26 mars 2021

Inserting elements in a range

I'm reading C++ Primer (5th edition) and in 9.9.3 it mentions inserting in-range elements.

It is clearly stated in the book that it will cause a runtime error if the range of the copy is the same as the target container.

// it'll cause a runtime error
vec.insert(vec.cbegin(), vec.cbegin(), vec.cend());

But it works in my computer, Why?

Aucun commentaire:

Enregistrer un commentaire