|
|
|
@ -11,7 +11,7 @@
|
|
|
|
template <typename T>
|
|
|
|
template <typename T>
|
|
|
|
class BaseIterator : public IIterator<T> {
|
|
|
|
class BaseIterator : public IIterator<T> {
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
explicit BaseIterator(T* ptr) : current(ptr) {}
|
|
|
|
explicit BaseIterator(T* ptr) : proxy{ptr, 0} {}
|
|
|
|
|
|
|
|
|
|
|
|
struct Proxy {
|
|
|
|
struct Proxy {
|
|
|
|
T* e;
|
|
|
|
T* e;
|
|
|
|
@ -20,24 +20,24 @@ public:
|
|
|
|
T& operator*() const { return *e; }
|
|
|
|
T& operator*() const { return *e; }
|
|
|
|
T* operator->() const { return e; }
|
|
|
|
T* operator->() const { return e; }
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
Proxy& operator*() { return proxy; }
|
|
|
|
|
|
|
|
|
|
|
|
Proxy& operator*() {
|
|
|
|
T* operator->() const override { return current(); }
|
|
|
|
proxy = Proxy{ current, this->level() };
|
|
|
|
operator const T*() const { return current(); }
|
|
|
|
return proxy;
|
|
|
|
operator T&() const { return *current(); }
|
|
|
|
}
|
|
|
|
operator T*() const { return current(); }
|
|
|
|
|
|
|
|
|
|
|
|
T* operator->() const override { return current; }
|
|
|
|
|
|
|
|
operator const T*() const { return current; }
|
|
|
|
|
|
|
|
operator T&() const { return *current; }
|
|
|
|
|
|
|
|
operator T*() const { return current; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool operator!=(const IIterator<T>& other) const override {
|
|
|
|
bool operator!=(const IIterator<T>& other) const override {
|
|
|
|
const T* other_current = other;
|
|
|
|
const T* other_current = other;
|
|
|
|
return current != other_current;
|
|
|
|
return current() != other_current;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
protected:
|
|
|
|
T* current;
|
|
|
|
T* current() const { return proxy.e; }
|
|
|
|
|
|
|
|
void set_current(T* e) { proxy.e = e; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
size_t level() const { return proxy.level; }
|
|
|
|
|
|
|
|
void set_level(size_t level) { proxy.level = level; }
|
|
|
|
private:
|
|
|
|
private:
|
|
|
|
Proxy proxy;
|
|
|
|
Proxy proxy;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|