Empty string: Difference between revisions

m
Line 463:
str = ""; // replace contents with empty string
str = {}; // swap contents with temp string (empty),then destruct temp
 
std::swap(str, {}); // swap contents with empty string (empty initializer list)
// swap with empty string
std::string tmp{}; // temp empty string
str.swap(tmp); // (builtin swap function)
std::swap(str, {}tmp); // swap contents with empty string (empty initializer list)tmp
 
 
// create an array of empty strings