aboutsummaryrefslogtreecommitdiff
path: root/src/server/shared
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2023-01-01 00:26:53 +0100
committerShauren <shauren.trinity@gmail.com>2023-08-12 14:24:24 +0200
commitb7287e85e4bc8acb2b95271ece9dd8a5b93873cd (patch)
tree6088602ac914ef69573ce551d7fc4f0613beb5ce /src/server/shared
parentf9033a5dbd559fde3030a21d83d664983d95f39f (diff)
Core/Misc: Fixed deprecation warnings for c++20
(cherry picked from commit ba9bbbc9d0c3b80d8954ad6390d23ae3d0f804b2)
Diffstat (limited to 'src/server/shared')
-rw-r--r--src/server/shared/DataStores/DBCStorageIterator.h72
1 files changed, 39 insertions, 33 deletions
diff --git a/src/server/shared/DataStores/DBCStorageIterator.h b/src/server/shared/DataStores/DBCStorageIterator.h
index 7f27be9b459..d4ac54bc64c 100644
--- a/src/server/shared/DataStores/DBCStorageIterator.h
+++ b/src/server/shared/DataStores/DBCStorageIterator.h
@@ -21,49 +21,55 @@
#include "Define.h"
#include <iterator>
-template <class T>
-class DBCStorageIterator : public std::iterator<std::forward_iterator_tag, T>
+template<class T>
+class DBCStorageIterator
{
- public:
- DBCStorageIterator() : _index(nullptr), _pos(0), _end(0) { }
- DBCStorageIterator(T** index, uint32 size, uint32 pos = 0) : _index(index), _pos(pos), _end(size)
+public:
+ using iterator_category = std::forward_iterator_tag;
+ using value_type = T;
+ using difference_type = std::ptrdiff_t;
+ using pointer = T*;
+ using reference = T&;
+
+ DBCStorageIterator() : _index(nullptr), _pos(0), _end(0) { }
+ DBCStorageIterator(T const* const* index, uint32 size, uint32 pos = 0) : _index(index), _pos(pos), _end(size)
+ {
+ if (_pos < _end)
{
- if (_pos < _end)
- {
- while (_pos < _end && !_index[_pos])
- ++_pos;
- }
+ while (_pos < _end && !_index[_pos])
+ ++_pos;
}
+ }
- T const* operator->() { return _index[_pos]; }
- T const* operator*() { return _index[_pos]; }
+ T const* operator->() const { return _index[_pos]; }
+ T const* operator*() const { return _index[_pos]; }
- bool operator==(DBCStorageIterator const& right) const { /*ASSERT(_index == right._index, "Iterator belongs to a different container")*/ return _pos == right._pos; }
- bool operator!=(DBCStorageIterator const& right) const { return !(*this == right); }
+ bool operator==(DBCStorageIterator const& right) const { /*ASSERT(_index == right._index, "Iterator belongs to a different container")*/ return _pos == right._pos; }
+ bool operator!=(DBCStorageIterator const& right) const { return !(*this == right); }
- DBCStorageIterator& operator++()
+ DBCStorageIterator& operator++()
+ {
+ if (_pos < _end)
{
- if (_pos < _end)
- {
- do
- ++_pos;
- while (_pos < _end && !_index[_pos]);
- }
-
- return *this;
+ do
+ ++_pos;
+ while (_pos < _end && !_index[_pos]);
}
- DBCStorageIterator operator++(int)
- {
- DBCStorageIterator tmp = *this;
- ++*this;
- return tmp;
- }
+ return *this;
+ }
+
+ DBCStorageIterator operator++(int)
+ {
+ DBCStorageIterator tmp = *this;
+ ++*this;
+ return tmp;
+ }
- private:
- T** _index;
- uint32 _pos;
- uint32 _end;
+private:
+ T const* const* _index;
+ uint32 _pos;
+ uint32 _end;
};
#endif // DBCStorageIterator_h__