diff options
author | Shauren <shauren.trinity@gmail.com> | 2024-09-09 23:21:23 +0200 |
---|---|---|
committer | Ovahlord <dreadkiller@gmx.de> | 2024-09-12 21:46:45 +0200 |
commit | 1c4f4c357479080e5664db69e97302676e471478 (patch) | |
tree | b5a59c227fd22cf8264604fdcf56d592b3de5f0f /src/server/shared | |
parent | e0ac52a75a727873f1f449a4a5c805b73d5c3de6 (diff) |
Core/DataStores: Refactor DBStorageIterator to make it usable with more std::ranges algorithms
(cherry picked from commit 8ec9b5841e9eef602f7b9ae8f8824eb799bf4c28)
Diffstat (limited to 'src/server/shared')
-rw-r--r-- | src/server/shared/DataStores/DB2Store.h | 2 | ||||
-rw-r--r-- | src/server/shared/DataStores/DBStorageIterator.h | 8 |
2 files changed, 5 insertions, 5 deletions
diff --git a/src/server/shared/DataStores/DB2Store.h b/src/server/shared/DataStores/DB2Store.h index 42afd22335f..362155552b2 100644 --- a/src/server/shared/DataStores/DB2Store.h +++ b/src/server/shared/DataStores/DB2Store.h @@ -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; diff --git a/src/server/shared/DataStores/DBStorageIterator.h b/src/server/shared/DataStores/DBStorageIterator.h index 6df777c76c9..0ccb1be5079 100644 --- a/src/server/shared/DataStores/DBStorageIterator.h +++ b/src/server/shared/DataStores/DBStorageIterator.h @@ -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; }; |