mercredi 2 août 2017

Does sorting a vector of std::wstring actually rewrite the raw string data?

Let's sort a vector of 1 million of strings with:

std::vector<std::wstring> v;           
// fill the vector
std::sort(v.begin(), v.end());

Does it:

  1. rewrite the vector with new wstrings, containing a few bytes for the wstring structure itself + a pointer to the unmodified actual raw data, without rewriting / moving the actual characters raw data

or

  1. rewrite the vector with new wstrings and the actual characters raw data is also rewritten / moved?

If the strings are, say, 100 character-long on average, I can imagine that 2. would be considerably slower than 1.

Which of these 2 situations is true on C++03 ? On C++11?

Aucun commentaire:

Enregistrer un commentaire