You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
746 B
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#pragma once
#include "ifaces/IIterator.h"
/// \brief Базовый итератор.
/// \tparam T Тип итерируемого элемента.
/// Предоставляет базовую реализацию методов для работы с итерируемыми объектами.
template <typename T>
class BaseIterator : public IIterator<T> {
protected:
T* current;
public:
explicit BaseIterator(T* ptr) : current(ptr) {}
T& operator*() const override { return *current; }
T* operator->() const override { return current; }
virtual operator const T*() const { return current; }
bool operator!=(const IIterator<T>& other) const override {
const T* other_current = other;
return current != other_current;
}
};