\brief Return the next element of the sequence, IterationTraits ::End() when the iteration is completed.
| 114 | /// \brief Return the next element of the sequence, IterationTraits<T>::End() when the |
| 115 | /// iteration is completed. |
| 116 | Result<T> Next() { |
| 117 | if (ptr_) { |
| 118 | auto next_result = next_(ptr_.get()); |
| 119 | if (next_result.ok() && IsIterationEnd(next_result.ValueUnsafe())) { |
| 120 | ptr_.reset(NULLPTR); |
| 121 | } |
| 122 | return next_result; |
| 123 | } else { |
| 124 | return IterationTraits<T>::End(); |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | /// Pass each element of the sequence to a visitor. Will return any error status |
| 129 | /// returned by the visitor, terminating iteration. |