forked from ryanhaining/cppitertools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcount_examples.cpp
More file actions
37 lines (32 loc) · 868 Bytes
/
count_examples.cpp
File metadata and controls
37 lines (32 loc) · 868 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
37
#include <count.hpp>
#include <iostream>
int main() {
std::cout << "count() counts towards infinity, breaks at 10\n";
for (auto i : iter::count()) {
std::cout << i << '\n';
if (i == 10) {
break;
}
}
std::cout << "count(20) starts counting from 20, breaks at 30\n";
for (auto i : iter::count(20)) {
std::cout << i << '\n';
if (i == 30) {
break;
}
}
std::cout << "count(50, 2) counts by 2 starting at 50, breaks at 70\n";
for (auto i : iter::count(50, 2)) {
std::cout << i << '\n';
if (i >= 70) {
break;
}
}
std::cout << "count(0, -1) counts down towards -infinity, breaks at -10\n";
for (auto i : iter::count(0, -1)) {
std::cout << i << '\n';
if (i == -10) {
break;
}
}
}