iter_swap (std::counted_iterator)
| Iterator concepts | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Iterator primitives | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Algorithm concepts and utilities | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Indirect callable concepts | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Common algorithm requirements | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Utilities | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Iterator adaptors | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | ||||
| Non-member functions | ||||
|
(C++20)
(C++20)
|
||||
|
(C++20)
|
||||
|
(C++20)
|
||||
|
(C++20)
|
||||
|
(C++20)
|
||||
|
(C++20)
|
||||
|
iter_swap
(C++20)
|
||||
| Helper classes | ||||
|
template
<
std::
indirectly_swappable
<
I
>
I2
>
friend
constexpr
void
|
(C++20以降) | |
2つの基盤となるイテレータが指すオブジェクトを交換します。 x. count ( ) または y. count ( ) が 0 に等しい場合、動作は未定義です。
この関数の本体は以下と等価です: ranges:: iter_swap ( x. base ( ) , y. base ( ) ) ; 。
この関数テンプレートは通常の unqualified lookup または qualified lookup では可視化されず、 argument-dependent lookup によってのみ発見され、その際 std:: counted_iterator < I > が引数の関連クラスである場合に限ります。
目次 |
パラメータ
| x, y | - | 交換する要素へのイテレータアダプタ |
戻り値
(なし)
計算量
定数。
例
#include <iostream> #include <iterator> #include <list> #include <vector> int main() { std::vector p{1, 2, 3, 4}, q{5, 6, 7, 8}; std::counted_iterator<std::vector<int>::iterator> ip{p.begin(), 2}; std::counted_iterator<std::vector<int>::iterator> iq{q.begin(), 3}; std::cout << *ip << ' ' << *iq << '\n'; iter_swap(ip, iq); // ADL std::cout << *ip << ' ' << *iq << '\n'; std::list x{0, 1, 3}; std::counted_iterator<std::list<int>::iterator> ix{x.begin(), 2}; // iter_swap(ip, ix); // error: not indirectly swappable }
出力:
1 5 5 1
関連項目
|
2つのオブジェクトの値を交換する
(関数テンプレート) |
|
|
2つの範囲の要素を交換する
(関数テンプレート) |
|
|
2つのイテレータが指す要素を交換する
(関数テンプレート) |
|
|
(C++20)
|
2つの間接参照可能なオブジェクトが参照する値を交換する
(カスタマイゼーションポイントオブジェクト) |
|
(C++20)
|
基盤となるイテレータの間接参照結果を、関連する右辺値参照型にキャストする
(関数) |