| 69 | class TInputRangeAdaptor { |
| 70 | public: // TODO: private |
| 71 | class TIterator { |
| 72 | public: |
| 73 | static constexpr bool IsNoexceptNext = noexcept(std::declval<TSlave>().Next()); |
| 74 | |
| 75 | using difference_type = std::ptrdiff_t; |
| 76 | using pointer = decltype(std::declval<TSlave>().Next()); |
| 77 | using reference = decltype(*std::declval<TSlave>().Next()); |
| 78 | using value_type = std::remove_cv_t<std::remove_reference_t<reference>>; |
| 79 | using iterator_category = std::input_iterator_tag; |
| 80 | |
| 81 | inline TIterator() noexcept |
| 82 | : Slave_(nullptr) |
| 83 | , Cur_() |
| 84 | { |
| 85 | } |
| 86 | |
| 87 | inline TIterator(TSlave* slave) noexcept(IsNoexceptNext) |
| 88 | : Slave_(slave) |
| 89 | , Cur_(Slave_->Next()) |
| 90 | { |
| 91 | } |
| 92 | |
| 93 | inline bool operator==(const TIterator& it) const noexcept { |
| 94 | return Cur_ == it.Cur_; |
| 95 | } |
| 96 | |
| 97 | inline bool operator!=(const TIterator& it) const noexcept { |
| 98 | return !(*this == it); |
| 99 | } |
| 100 | |
| 101 | inline pointer operator->() const noexcept { |
| 102 | return Cur_; |
| 103 | } |
| 104 | |
| 105 | inline reference operator*() const noexcept { |
| 106 | return *Cur_; |
| 107 | } |
| 108 | |
| 109 | inline TIterator& operator++() noexcept(IsNoexceptNext) { |
| 110 | Cur_ = Slave_->Next(); |
| 111 | |
| 112 | return *this; |
| 113 | } |
| 114 | |
| 115 | private: |
| 116 | TSlave* Slave_; |
| 117 | pointer Cur_; |
| 118 | }; |
| 119 | |
| 120 | public: |
| 121 | using const_iterator = TIterator; |