forked from ryanhaining/cppitertools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestslice.cpp
More file actions
36 lines (34 loc) · 982 Bytes
/
Copy pathtestslice.cpp
File metadata and controls
36 lines (34 loc) · 982 Bytes
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
#include <slice.hpp>
#include <iostream>
#include <vector>
#include <array>
int main() {
std::cout << std::endl << "Slice range test" << std::endl << std::endl;
std::vector<int> a{0,1,2,3,4,5,6,7,8,9,10,11,12,13};
std::vector<std::string> b{"hey","how","are","you","doing"};
for (auto i : iter::slice(a,2)) {
std::cout << i << std::endl;
}
std::cout<<std::endl;
for (auto & s : iter::slice(b,3,4)) {
std::cout << s << std::endl;
s = "test";
}
std::cout<<std::endl;
for (auto s : b) {
std::cout << s << std::endl;
}
std::cout<<std::endl;
for (auto i : iter::slice(a,0,15,3)) {
std::cout << i << std::endl;
}
std::cout<<std::endl;
for (auto i : iter::slice(a,13,-1,-1)) {
std::cout << i << std::endl;
}
std::cout<<std::endl;
for (auto i : iter::slice(a,1,10,-1)) {
//invalid range returns two begin iters
std::cout << i << std::endl;
}
}