std::tuple::swap
来自cppreference.com
![]() |
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
在头文件 <tuple> 中定义
|
||
void swap( tuple& other ); |
(C++11 起) | |
调用std::swap*this中的每个元素和其对应的元素在
other
.原文:
Calls std::swap for each element in *this and its corresponding element in
other
.目录 |
[编辑] 参数
other | - | 元组的值进行交换
|
[编辑] 返回值
(无)
[编辑] 例外
noexcept specification: (C++11 起)
noexcept( noexcept(swap(std::declval<T0&>>(), std::declval<T0&>())) && |
||
[编辑] 示例
#include <iostream> #include <tuple> #include <string> int main() { std::tuple<int, std::string, float> p1, p2; p1 = std::make_tuple(10, "test", 3.14); p2.swap(p1); std::cout << "(" << std::get<0>(p2) << ", " << std::get<1>(p2) << ", " << std::get<2>(p2) << ")\n"; }
输出:
(10, test, 3.14)