Kagome
Polkadot Runtime Engine in C++17
generic_iterator.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_GENERIC_ITERATOR_HPP
7 #define KAGOME_GENERIC_ITERATOR_HPP
8 
9 #include <memory>
10 
11 namespace kagome::face {
12 
17  template <typename Container>
19  public:
20  using value_type = typename Container::value_type;
21 
22  virtual ~GenericIterator() = default;
23 
24  // needed as there's no simple way to copy an object by a pointer to its
25  // abstract interface
26  virtual std::unique_ptr<GenericIterator> clone() const = 0;
27 
28  virtual value_type *get() = 0;
29  virtual value_type const *get() const = 0;
30 
31  virtual value_type &operator*() = 0;
32  virtual value_type const &operator*() const = 0;
33 
35 
37  return **this;
38  }
39 
40  virtual bool operator!=(const GenericIterator<Container> &other) const {
41  return get() != other.get();
42  }
43 
45  return get() == other.get();
46  }
47  };
48 
49 } // namespace kagome::face
50 
51 #endif // KAGOME_GENERIC_ITERATOR_HPP
bool operator==(const GenericIterator< Container > &other)
virtual bool operator!=(const GenericIterator< Container > &other) const
typename Container::value_type value_type
virtual ~GenericIterator()=default
virtual GenericIterator< Container > & operator++()=0
virtual std::unique_ptr< GenericIterator > clone() const =0
virtual value_type & operator*()=0
virtual value_type * get()=0