We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Given two string variables, swap the contents without using a temporary variable.
std::string provides the swap() member function for this purpose:
std::string
swap()
std::string one{"This is string one"}; std::string two("This is string two"}; one.swap(two);
std::string::swap() exchanges the internal state of two non-const instances without copying any data.
std::string::swap()
const