-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrange.hpp
More file actions
40 lines (34 loc) · 952 Bytes
/
Copy pathrange.hpp
File metadata and controls
40 lines (34 loc) · 952 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
38
39
40
#pragma once
namespace itertools {
class range {
private:
int _first;
int _last;
public:
range(int first, int last) : _first(first), _last(last) {}
class iterator {
int value;
public:
iterator(int v = 0) : value(v) {}
// iterator &operator=(const iterator &other) {
// if (this != &other)
// this->value = other.value;
// return *this;
// }
int operator*() const { return value; }
iterator &operator++() {
value++;
return *this;
}
iterator operator++(int) {
iterator temp = *this;
value++;
return temp;
}
bool operator==(const iterator &it) const { return value == it.value; }
bool operator!=(const iterator &it) const { return value != it.value; }
};
iterator begin() const { return iterator(_first); }
iterator end() const { return iterator(_last); }
};
} // namespace itertools