- 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
constexpr void
swap(const tuple& rhs) const noexcept(see below); // (2) C++23- (1) :
tupleの全ての要素型がswap可能であること。 - (2) : C++23 :
(is_swappable_v<const Types> && ...) == trueであること。
なし
- (1) :
tupleの全ての要素型が、例外を投げないswapを持っている場合、この関数は例外を投げない - (2) : C++23 :
(is_nothrow_swappable_v<const Types> && ...) == trueであること。
#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]
- C++11
- Clang:
- GCC: 4.6.1 [mark verified]
- ICC:
- Visual C++: