public member function
<string>
std::string::swap
Swap string values
After the call to this member function, the value of this object is the value str had before the call, and the value of str is the value this object had before the call.
Notice that a non-member function exists with the same name, swap, overloading that algorithm with an optimization that behaves like this member function.
Parameters
Return value
noneExample
|
|
Output:
Before the swap, buyer has money and seller has goods After the swap, buyer has goods and seller has money
Complexity
Constant.Iterator validity
Any iterators, pointers and references related to this object and to str may be invalidated.Data races
Both the object and str are modified.Exception safety
No-throw guarantee: this member function never throws exceptions.See also
- swap (string)
- Exchanges the values of two strings (function)
- swap_ranges
- Exchange values of two ranges (function template)