On this page
std::basic_string_view<CharT,Traits>::swap
|
(since C++17) |
Exchanges the view with that of v
.
Parameters
v | - | view to swap with |
Return value
(none)
Complexity
Constant.
Example
#include <iostream>
#include <string_view>
int main()
{
std::string_view a = "AAA";
std::string_view b = "BBBB";
std::cout << "Before swap:\n"
"a = " << a << "\n"
"b = " << b << "\n\n";
a.swap(b);
std::cout << "After swap:\n"
"a = " << a << "\n"
"b = " << b << '\n';
}
Output:
Before swap:
a = AAA
b = BBBB
After swap:
a = BBBB
b = AAA
See also
swaps the values of two objects (function template) |
|
swaps two ranges of elements (function template) |
|
swaps the contents (public member function of std::basic_string<CharT,Traits,Allocator> ) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/string/basic_string_view/swap