std::basic_string_view::swap - std::basic_string_view::swap
constexpr void swap( basic_string_view& v ) noexcept;
(since C++17)
Exchanges the view with that of v.
// Run this code
#include <string_view>
#include <iostream>
int main() {
auto s1{
std::string_view{"⏺⏺⏺⏺⏺"} };
auto s2{
std::string_view{"⏹⏹⏹⏹⏹"}
};
std::cout << "Before : " << s1 << ' ' << s2
<< "\n";
s1.swap(s2);
std::cout << "After : " << s1 << ' ' << s2
<< "\n";
}
Before : ⏺⏺⏺⏺⏺
⏹⏹⏹⏹⏹
After : ⏹⏹⏹⏹⏹
⏺⏺⏺⏺⏺
swap swaps the values of two objects
(function template)
swap_ranges swaps two ranges of elements
(function template)
swap swaps the contents
(public member function of
std::basic_string<CharT,Traits,Allocator>)