jeudi 21 septembre 2017

Will clearing a std::string still preserve its original size

Suppose I have a function like this

void fooMethod() {
  std::string foo;
  foo.resize(40);
  bar(foo)
}

void bar(std::string& bar)
{
   bar.clear();
   bar += xxxx;
}

My question is will clear still maintain the original size of the string ? My assumption is yes because std::string in C++ are mutable please let me know if I am correct ?

Aucun commentaire:

Enregistrer un commentaire