forked from n3554/n3554
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswap_ranges.cpp
51 lines (39 loc) · 911 Bytes
/
swap_ranges.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <algorithm>
#include <vector>
#include <numeric>
#include <iostream>
int main()
{
std::vector<int> x(10), y(10);
std::iota(x.begin(), x.end(), 0);
std::iota(y.begin(), y.end(), 10);
std::swap_ranges(std::seq, x.begin(), x.end(), y.begin());
std::cout << "swap_ranges result: " << std::endl;
std::cout << "x: ";
for(int i = 0; i < x.size(); ++i)
{
std::cout << x[i] << " ";
}
std::cout << std::endl;
std::cout << "y: ";
for(int i = 0; i < y.size(); ++i)
{
std::cout << y[i] << " ";
}
std::cout << std::endl;
std::cout << std::endl;
std::swap_ranges(std::par, x.begin(), x.end(), y.begin());
std::cout << "x: ";
for(int i = 0; i < x.size(); ++i)
{
std::cout << x[i] << " ";
}
std::cout << std::endl;
std::cout << "y: ";
for(int i = 0; i < y.size(); ++i)
{
std::cout << y[i] << " ";
}
std::cout << std::endl;
return 0;
}