The Wayback Machine - https://web.archive.org/web/20161016164313/http://ja.cppreference.com:80/w/cpp/algorithm/swap
名前空間
変種
操作

std::swap

提供: cppreference.com
< cpp‎ | algorithm

 
 
アルゴリズムライブラリ
機能します
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
シーケンス動作を非改変
Original:
Non-modifying sequence operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
シーケンス動作を変更する
Original:
Modifying sequence operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
操作を仕切る
Original:
Partitioning operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(ソートされた範囲で)ソート操作
Original:
Sorting operations (on sorted ranges)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
バイナリ検索操作(ソート範囲で)
Original:
Binary search operations (on sorted ranges)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(ソートされた範囲で)操作を設定します
Original:
Set operations (on sorted ranges)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ヒープ操作
Original:
Heap operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
最小値/最大値操作
Original:
Minimum/maximum operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
数値演算
Original:
Numeric operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Cライブラリ
Original:
C library
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
 
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) 値abをスワップする。

2) 配列abをスワップする。実質的にstd::swap_ranges(a, a+N, b)を呼び出す。

目次

[編集]パラメータ

a, b - スワップされる値
型の要件
-
TMoveAssignable and MoveConstructible
-
T2Swappable

の要求を満足しなければなりません。

[編集]値を返します

(なし)

[編集]例外

1)
noexcept specification:  (C++11およびそれ以降)
noexcept(noexcept(

    std::is_nothrow_move_constructible<T>::value&&
    std::is_nothrow_move_assignable<T>::value

))
2)
noexcept specification:  (C++11およびそれ以降)
noexcept(noexcept(swap(*a, *b)))

[編集]複雑性

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.
次のオーバーロードは、すでに標準ライブラリで提供されています
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.
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.

(関数テンプレート)[edit]
std::swapアルゴリズムのテンプレート特殊化です。
(関数テンプレート)[edit]
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.

(関数テンプレート)[edit]
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.

(関数テンプレート)[edit]
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.

(関数テンプレート)[edit]
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.

(関数テンプレート)[edit]
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.

(関数テンプレート)[edit]
特殊化されたstd::swapアルゴリズム
(関数テンプレート)[edit]
特殊化されたstd::swapアルゴリズム
(関数テンプレート)[edit]
特殊化されたstd::swapアルゴリズム
(関数テンプレート)[edit]
特殊化されたstd::swapアルゴリズム
(関数テンプレート)[edit]
特殊化されたstd::swapアルゴリズム
(関数テンプレート)[edit]
特殊化されたstd::swapアルゴリズム
(関数テンプレート)[edit]
特殊化されたstd::swapアルゴリズム
(関数テンプレート)[edit]
特殊化されたstd::swapアルゴリズム
(関数テンプレート)[edit]
特殊化されたstd::swapアルゴリズム
(関数テンプレート)[edit]
特殊化されたstd::swapアルゴリズム
(関数テンプレート)[edit]
特殊化されたstd::swapアルゴリズム
(関数テンプレート)[edit]
特殊化されたstd::swapアルゴリズム
(関数テンプレート)[edit]
特殊化されたstd::swapアルゴリズム
(関数テンプレート)[edit]
特殊化されたstd::swapアルゴリズム
(関数テンプレート)[edit]
特殊化されたstd::swapアルゴリズム
(関数テンプレート)[edit]
特殊化されたstd::swapアルゴリズム
(関数テンプレート)[edit]
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.

(関数テンプレート)
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.

(関数テンプレート)
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.

(関数テンプレート)[edit]
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.

(関数テンプレート)[edit]
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.

(関数テンプレート)[edit]
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.

(関数テンプレート)[edit]
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.

(関数テンプレート)

[編集]

[編集]参照

スワップ二つのイテレータが指す要素
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.

(関数テンプレート)[edit]
スワップの要素の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.

(関数テンプレート)[edit]
close