forked from ryanhaining/cppitertools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcycle_examples.cpp
More file actions
30 lines (26 loc) · 611 Bytes
/
Copy pathcycle_examples.cpp
File metadata and controls
30 lines (26 loc) · 611 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
#include <cycle.hpp>
#include <vector>
#include <string>
#include <iostream>
int main() {
size_t count = 0;
std::cout << "cycle({2, 4, 6}) run 20 times:\n";
std::vector<int> vec = {2, 4, 6};
for (auto&& i : iter::cycle(vec)) {
std::cout << i << '\n';
if (count == 20) {
break;
}
++count;
}
std::cout << "cycle(\"hello\") run 20 times:\n";
count = 0;
const std::string s("hello");
for (auto&& c : iter::cycle(s)) {
std::cout << c << '\n';
if (count == 20) {
break;
}
++count;
}
}