Core/DataStores: Refactor DBStorageIterator to make it usable with more std::ranges algorithms

This commit is contained in:
Shauren
2024-09-09 23:21:23 +02:00
parent aa6ec35195
commit 8ec9b5841e
2 changed files with 5 additions and 5 deletions

View File

@@ -76,7 +76,7 @@ class DB2Storage : public DB2StorageBase
static_assert(std::is_standard_layout_v<T>, "T in DB2Storage must have standard layout.");
public:
using iterator = DBStorageIterator<T>;
using iterator = DBStorageIterator<T const*>;
using DB2StorageBase::DB2StorageBase;

View File

@@ -32,7 +32,7 @@ public:
using reference = T&;
DBStorageIterator() : _index(nullptr), _pos(0), _end(0) { }
DBStorageIterator(T const* const* index, uint32 size, uint32 pos = 0) : _index(index), _pos(pos), _end(size)
DBStorageIterator(value_type const* index, uint32 size, uint32 pos = 0) : _index(index), _pos(pos), _end(size)
{
if (_pos < _end)
{
@@ -41,8 +41,8 @@ public:
}
}
T const* operator->() const { return _index[_pos]; }
T const* operator*() const { return _index[_pos]; }
value_type const& operator->() const { return _index[_pos]; }
value_type const& operator*() const { return _index[_pos]; }
bool operator==(DBStorageIterator const& right) const { /*ASSERT(_index == right._index, "Iterator belongs to a different container")*/ return _pos == right._pos; }
@@ -66,7 +66,7 @@ public:
}
private:
T const* const* _index;
value_type const* _index;
uint32 _pos;
uint32 _end;
};