| 10513 | // and implements the const forward iterator concept. |
| 10514 | template <typename T> |
| 10515 | class ParamIterator { |
| 10516 | public: |
| 10517 | typedef T value_type; |
| 10518 | typedef const T& reference; |
| 10519 | typedef ptrdiff_t difference_type; |
| 10520 | |
| 10521 | // ParamIterator assumes ownership of the impl_ pointer. |
| 10522 | ParamIterator(const ParamIterator& other) : impl_(other.impl_->Clone()) {} |
| 10523 | ParamIterator& operator=(const ParamIterator& other) { |
| 10524 | if (this != &other) |
| 10525 | impl_.reset(other.impl_->Clone()); |
| 10526 | return *this; |
| 10527 | } |
| 10528 | |
| 10529 | const T& operator*() const { return *impl_->Current(); } |
| 10530 | const T* operator->() const { return impl_->Current(); } |
| 10531 | // Prefix version of operator++. |
| 10532 | ParamIterator& operator++() { |
| 10533 | impl_->Advance(); |
| 10534 | return *this; |
| 10535 | } |
| 10536 | // Postfix version of operator++. |
| 10537 | ParamIterator operator++(int /*unused*/) { |
| 10538 | ParamIteratorInterface<T>* clone = impl_->Clone(); |
| 10539 | impl_->Advance(); |
| 10540 | return ParamIterator(clone); |
| 10541 | } |
| 10542 | bool operator==(const ParamIterator& other) const { |
| 10543 | return impl_.get() == other.impl_.get() || impl_->Equals(*other.impl_); |
| 10544 | } |
| 10545 | bool operator!=(const ParamIterator& other) const { |
| 10546 | return !(*this == other); |
| 10547 | } |
| 10548 | |
| 10549 | private: |
| 10550 | friend class ParamGenerator<T>; |
| 10551 | explicit ParamIterator(ParamIteratorInterface<T>* impl) : impl_(impl) {} |
| 10552 | std::unique_ptr<ParamIteratorInterface<T> > impl_; |
| 10553 | }; |
| 10554 | |
| 10555 | // ParamGeneratorInterface<T> is the binary interface to access generators |
| 10556 | // defined in other translation units. |