-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
47 lines (34 loc) · 1.04 KB
/
main.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
#include <array>
#include <iostream>
#include <iterator>
#include <list>
#include "iterzip.hpp"
using iterzip::zip;
int main() {
std::list<int> a{1,2,3,4,5};
std::list<int> b{6,7,8,9,10};
using T1 = decltype(a.begin());
using T2 = decltype(a.begin());
using cat = typename iterzip::iterator_traits<T1,T2>::iterator_category;
auto zipped = zip(a, b);
for(auto iter = zipped.begin(); iter != zipped.end(); iter++) {
auto x = std::get<0>(*iter);
auto& y = std::get<1>(*iter);
std::cout << x << ", " << y << std::endl;
x = 5;
}
std::cout << std::endl;
for(auto [x,y] : zip(a,b)) {
std::cout << x << ", " << y << std::endl;
}
std::cout << std::endl;
std::array<int, 3> d{1,2,3};
std::array<int, 2> e{3,4};
auto zipped2 = zip(d, e);
// only works with random access iterators
std::cout << std::get<0>(zipped2.begin()[1]) << std::endl;
std::cout << std::endl;
for(auto [x,y] : zip(d,e)) {
std::cout << x << ", " << y << std::endl;
}
}