vendredi 4 octobre 2019

Lifetime of the object returned by std::string::substr

I need to know whether the following is valid in general.

string s = "some value";
string v = s.substr(0, 50).c_str();

Is the assignment to v always valid? Can there be any issues due to the temporary lifetime of object returned by substr()

Aucun commentaire:

Enregistrer un commentaire