forked from ryanhaining/cppitertools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtesttakewhile.cpp
More file actions
32 lines (25 loc) · 778 Bytes
/
Copy pathtesttakewhile.cpp
File metadata and controls
32 lines (25 loc) · 778 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
#include <takewhile.hpp>
#include <range.hpp>
#include <vector>
#include <iostream>
using iter::takewhile;
using iter::range;
int main() {
std::vector<int> ivec{1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1};
for (auto i : takewhile([] (int i) {return i < 5;}, ivec)) {
std::cout << i << '\n';
}
for (auto i : takewhile([] (int i) {return i < 5;}, range(10))) {
std::cout << i << '\n';
}
for (auto i : takewhile([] (int i) {return i < 5;},
{1, 2, 3, 4, 5, 6, 7, 8, 9})) {
std::cout << i << '\n';
}
std::cout << "with temporary\n";
for (auto i : takewhile([] (int i) {return i < 5;},
std::vector<int>{1, 2, 3, 4, 5, 6, 7, 8, 9})) {
std::cout << i << '\n';
}
return 0;
}