std::basic_string_view<CharT,Traits>::swap
出自cppreference.com
| |
(C++17 起) | |
交換視圖與 v 的內容。
參數
| v | - | 要與之交換的視圖 |
��回值
(無)
複雜度
常數。
示例
運行此代碼
#include <iostream>
#include <string_view>
int main()
{
std::string_view a = "AAA";
std::string_view b = "BBBB";
std::cout << "交换前:\n"
"a = " << a << "\n"
"b = " << b << "\n\n";
a.swap(b);
std::cout << "交换后:\n"
"a = " << a << "\n"
"b = " << b << '\n';
}
輸出:
交换前:
a = AAA
b = BBBB
交换后:
a = BBBB
b = AAA
參閱
| 交換兩個對象的值 (函數模板) | |
| 交換兩個範圍的元素 (函數模板) | |
| 交換內容 ( std::basic_string<CharT,Traits,Allocator> 的公開成員函數)
|