forked from ryanhaining/cppitertools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestrepeat.cpp
More file actions
31 lines (27 loc) · 723 Bytes
/
Copy pathtestrepeat.cpp
File metadata and controls
31 lines (27 loc) · 723 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
#include "repeat.hpp"
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <memory>
int main () {
int a = 10;
int i = 0;
for (auto num : iter::repeat(a)) {//goes infintely
std::cout << num << std::endl;
++i;
if (i > 20) break;
}
std::cout<<std::endl;
for (auto num : iter::repeat(a,10)) {//goes ten times
std::cout << num << std::endl;
}
std::cout << "with temporary\n";
for (auto s : iter::repeat(std::string{"hey"}, 2)) {
std::cout << s << '\n';
}
std::cout << "with uptr temporary\n";
for (auto& p : iter::repeat(std::unique_ptr<int>{new int{2}}, 2)) {
std::cout << *p << '\n';
}
}