c++ - Does a vector sort invalidate iterators? -


 std::vector<string> names;  std::vector<string>::iterator start = names.begin();  std::vector<string>::iterator end = names.end();  sort (start,end);  //are start , end valid @ point?  //or not point front , tail resp? 

according c++ standard §23.1/11:

unless otherwise specified (either explicitly or defining function in terms of other functions), invoking container member function or passing container argument a library function shall not invalidate iterators to, or change values of, objects within container.

§25.3 "sorting , related operations" doesn't specify iterators invalidated, iterators in question should stay valid.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -