namespace std {
template <class... Types>
void swap(tuple<Types...>& x, tuple<Types...>& y)
noexcept(noexcept(x.swap(y))); // (1) C++11
template <class... Types>
constexpr void swap(tuple<Types...>& x, tuple<Types...>& y)
noexcept(noexcept(x.swap(y))); // (1) C++20
}
概要
2つのtuple
オブジェクトを入れ替える。
効果
x.swap(y);
戻り値
なし
例外
効果の式が例外を投げない場合、この関数は決して例外を投げない。
例
#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");
std::swap(a, b);
assert(a == std::make_tuple(2, 'b', "good-bye"));
assert(b == std::make_tuple(1, 'a', "hello"));
}
出力
バージョン
言語
- C++11
処理系
- Clang: 3.0
- GCC: 4.3
- ICC: ??
- Visual C++: ??