- tuple[meta header]
- std[meta namespace]
- tuple[meta class]
- function[meta id-type]
- cpp11[meta cpp]
void swap(tuple& rhs) noexcept(see below); // (1) C++11
constexpr void swap(tuple& rhs) noexcept(see below); // (1) C++20
- see below[italic]
他のtuple
オブジェクトと中身を入れ替える。
tuple
の全ての要素型がswap
可能であること。
自身のインスタンスの全ての要素を、rhs
の全ての要素と入れ替える
なし
tuple
の全ての要素型が、例外を投げないswap
を持っている場合、この関数は例外を投げない
#include <string>
#include <tuple>
#include <cassert>
int main()
{
std::tuple<int, char, std::string> a(1, 'a', "hello");
std::tuple<int, char, std::string> b(2, 'b', "good-bye");
a.swap(b);
assert(a == std::make_tuple(2, 'b', "good-bye"));
assert(b == std::make_tuple(1, 'a', "hello"));
}
- swap[color ff0000]
- std::make_tuple[link /reference/tuple/make_tuple.md]
- C++11
- Clang:
- GCC: 4.6.1
- ICC:
- Visual C++: