libraries: Drop std::iterator template usage.

Define iterator traits manually instead of using deprecated std:iterator template.

See https://www.fluentcpp.com/2018/05/08/std-iterator-deprecated/

This fixes a C++17 deprecation warning and C++20 error on GCC 14.
This commit is contained in:
Lubosz Sarnecki 2024-08-03 13:42:36 +02:00
parent 473a5dc79d
commit 91076e2000
2 changed files with 10 additions and 2 deletions

View file

@ -198,9 +198,14 @@ public:
//Template iterator with random access on the buffer sysmem
template<typename T>
class Iterator : public std::iterator<std::random_access_iterator_tag, T, Index, T*, T&>
class Iterator
{
public:
using iterator_category = std::random_access_iterator_tag;
using value_type = T;
using difference_type = Index;
using pointer = T*;
using reference = T&;
Iterator(T* ptr = NULL, int stride = sizeof(T)): _ptr(ptr), _stride(stride) { }
Iterator(const Iterator<T>& iterator) = default;

View file

@ -103,8 +103,11 @@ private:
std::vector<T> _buffer;
public:
class Iterator : public std::iterator < std::random_access_iterator_tag, T > {
class Iterator {
public:
using iterator_category = std::random_access_iterator_tag;
using value_type = T;
Iterator(T* bufferFirst, T* bufferLast, T* newestAt, T* at)
: _bufferFirst(bufferFirst),
_bufferLast(bufferLast),