std::swap
提供: cppreference.com
![]() | このページは、Google 翻訳を使って英語版から機械翻訳されました。 翻訳には誤りや奇妙な言い回しがあるかもしれません。文章の上にポインタをおくと、元の文章が見れます。誤りを修正して翻訳を改善する手助けをしてください。翻訳についての説明は、ここをクリックしてください。 |
Defined in header <algorithm> Defined in header <utility> | (C++11以前) (C++11およびそれ以降) | |
template<class T > void swap( T& a, T& b ); | (1) | |
template<class T2, size_t N > void swap( T2 (&a)[N], T2 (&b)[N]); | (2) | (C++11およびそれ以降) |
値を交換する。
1) 値a
とb
をスワップする。
2) 配列a
とb
をスワップする。実質的にstd::swap_ranges(a, a+N, b)を呼び出す。
目次 |
[編集]パラメータ
a, b | - | スワップされる値 |
型の要件 | ||
-T は MoveAssignable and MoveConstructible 。 | ||
-T2 は Swappable の要求を満足しなければなりません。 |
[編集]値を返します
(なし)
[編集]例外
1)noexcept specification: (C++11およびそれ以降)
2) noexcept(noexcept( std::is_nothrow_move_constructible<T>::value&& | ||
[編集]複雑性
1) 定数
2) Nの線形
[編集]特殊化
で線形。 std::swapアルゴリズムの両方で、カスタムの専門化とオーバーロードは許可されますが、関数テンプレートの特殊化、テンプレートクラスに対して許可されていませんので、オーバーロードが一般的に好ましい。それらは引数依存ルックアップ(
Swappable
コンセプトごとなど)によって発見された場合、スワップするときは、ライブラリ関数は、常にユーザーが提供するオーバーロードを使用して.Original:
Both custom specializations and overloads of the std::swap algorithm are allowed, but the overloads are generally preferred since specializations of a function template aren't allowed for template classes. Library functions always use the user-provided overloads when swapping, if they are found by argument-dependent lookup (as per
Swappable
concept).The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
次のオーバーロードは、すでに標準ライブラリで提供されています
Original:
The following overloads are already provided by the standard library:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
(C++11) | std::swapアルゴリズムを特化しています Original: specializes the std::swap algorithm The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) |
(C++11) | std::swapアルゴリズムのテンプレート特殊化です。 (関数テンプレート) |
(C++11) | std::swapアルゴリズムを専門としています Original: specializes the std::swap algorithm The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) |
(C++11) | std::swapアルゴリズムを専門としています Original: specializes the std::swap algorithm The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) |
(C++11) | std::swapアルゴリズムを専門としています Original: specializes the std::swap algorithm The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) |
(C++11) | std::swapアルゴリズムを専門としています Original: specializes the std::swap algorithm The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) |
std::swapアルゴリズムを専門としています Original: specializes the std::swap algorithm The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
特殊化されたstd::swapアルゴリズム (関数テンプレート) | |
特殊化されたstd::swapアルゴリズム (関数テンプレート) | |
特殊化されたstd::swapアルゴリズム (関数テンプレート) | |
特殊化されたstd::swapアルゴリズム (関数テンプレート) | |
特殊化されたstd::swapアルゴリズム (関数テンプレート) | |
特殊化されたstd::swapアルゴリズム (関数テンプレート) | |
特殊化されたstd::swapアルゴリズム (関数テンプレート) | |
特殊化されたstd::swapアルゴリズム (関数テンプレート) | |
特殊化されたstd::swapアルゴリズム (関数テンプレート) | |
特殊化されたstd::swapアルゴリズム (関数テンプレート) | |
特殊化されたstd::swapアルゴリズム (関数テンプレート) | |
特殊化されたstd::swapアルゴリズム (関数テンプレート) | |
特殊化されたstd::swapアルゴリズム (関数テンプレート) | |
特殊化されたstd::swapアルゴリズム (関数テンプレート) | |
特殊化されたstd::swapアルゴリズム (関数テンプレート) | |
特殊化されたstd::swapアルゴリズム (関数テンプレート) | |
(C++11) | std::swap() アルゴリズムを専門としていますOriginal: specializes the std::swap() algorithmThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) |
std::swap() アルゴリズムを専門としていますOriginal: specializes the std::swap() algorithmThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
std::swap() アルゴリズムを専門としていますOriginal: specializes the std::swap() algorithmThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
std::swap() アルゴリズムを専門としていますOriginal: specializes the std::swap() algorithmThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
std::swap() アルゴリズムを専門としていますOriginal: specializes the std::swap() algorithmThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
std::swap() アルゴリズムを専門としていますOriginal: specializes the std::swap() algorithmThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
std::swapアルゴリズムを専門としています Original: specializes the std::swap algorithm The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
std::swapアルゴリズムを専門としています Original: specializes the std::swap algorithm The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
std::swapアルゴリズムを専門としています Original: specializes the std::swap algorithm The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
(C++11) | std::swap() アルゴリズムを専門としていますOriginal: specializes the std::swap() algorithmThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) |
std::swap() アルゴリズムを専門としていますOriginal: specializes the std::swap() algorithmThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
(C++11) | std::swapアルゴリズムを専門としています Original: specializes the std::swap algorithm The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) |
(C++11) | std::swap() アルゴリズムを専門としていますOriginal: specializes the std::swap() algorithmThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) |
(C++11) | std::swap() アルゴリズムを専門としていますOriginal: specializes the std::swap() algorithmThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) |
std::swap() アルゴリズムを専門としていますOriginal: specializes the std::swap() algorithmThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) |
[編集]例
This section is incomplete Reason: no example |
[編集]参照
スワップ二つのイテレータが指す要素 Original: swaps the elements pointed to by two iterators The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
スワップの要素の2つの範囲を Original: swaps two ranges of elements The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) |