Skip to content

Commit eabe0dc

Browse files
committed
repeat iterator is input iterator
1 parent 16b9f35 commit eabe0dc

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

repeat.hpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef REPEAT_HPP__
2-
#define REPEAT_HPP__
1+
#ifndef ITER_REPEAT_HPP_
2+
#define ITER_REPEAT_HPP_
33

44
#include <iterator>
55
#include <utility>
@@ -28,7 +28,7 @@ namespace iter {
2828
{ }
2929
public:
3030

31-
class Iterator {
31+
class Iterator : public std::iterator<std::input_iterator_tag, T> {
3232
private:
3333
T& elem;
3434
int count;
@@ -49,11 +49,21 @@ namespace iter {
4949
return *this;
5050
}
5151

52+
Iterator operator++(int) {
53+
auto ret = *this;
54+
++*this;
55+
return ret;
56+
}
57+
5258
bool operator!=(const Iterator& other) const {
5359
return this->count != other.count ||
5460
&this->elem != &other.elem;
5561
}
5662

63+
bool operator==(const Iterator& other) const {
64+
return !(*this != other);
65+
}
66+
5767
T& operator*() {
5868
return this->elem;
5969
}
@@ -76,4 +86,4 @@ namespace iter {
7686

7787
}
7888

79-
#endif //REPEAT_HPP__
89+
#endif

0 commit comments

Comments
 (0)