From 04c5f76de1e0ed60f668c8d969d1c5a6a0191495 Mon Sep 17 00:00:00 2001 From: mikee47 Date: Fri, 19 May 2023 11:24:51 +0100 Subject: [PATCH] Use of `std::iterator` is deprecated --- Sming/Components/FlashString | 2 +- Sming/Components/Storage/src/include/Storage/Iterator.h | 8 +++++++- Sming/Core/Data/LinkedObject.h | 9 +++++++-- Sming/Wiring/WHashMap.h | 9 +++++++-- Sming/Wiring/WVector.h | 8 +++++++- 5 files changed, 29 insertions(+), 7 deletions(-) diff --git a/Sming/Components/FlashString b/Sming/Components/FlashString index 0045c67179..1025908632 160000 --- a/Sming/Components/FlashString +++ b/Sming/Components/FlashString @@ -1 +1 @@ -Subproject commit 0045c67179833555256e2c3e0e3b82eaca3dc851 +Subproject commit 10259086321ebeceb6b7106b4697c9caef9956e6 diff --git a/Sming/Components/Storage/src/include/Storage/Iterator.h b/Sming/Components/Storage/src/include/Storage/Iterator.h index c17662693c..eef88b9501 100644 --- a/Sming/Components/Storage/src/include/Storage/Iterator.h +++ b/Sming/Components/Storage/src/include/Storage/Iterator.h @@ -15,9 +15,15 @@ namespace Storage { class Device; -class Iterator : public std::iterator +class Iterator { public: + using iterator_category = std::forward_iterator_tag; + using value_type = Partition; + using difference_type = std::ptrdiff_t; + using pointer = Partition*; + using reference = Partition&; + Iterator(Device& device) : mSearch{&device, Partition::Type::any, Partition::SubType::any}, mDevice(&device) { next(); diff --git a/Sming/Core/Data/LinkedObject.h b/Sming/Core/Data/LinkedObject.h index 14d58d8cd0..7d8b25f781 100644 --- a/Sming/Core/Data/LinkedObject.h +++ b/Sming/Core/Data/LinkedObject.h @@ -61,10 +61,15 @@ class LinkedObject template class LinkedObjectTemplate : public LinkedObject { public: - template - class IteratorTemplate : public std::iterator + template class IteratorTemplate { public: + using iterator_category = std::forward_iterator_tag; + using value_type = T; + using difference_type = std::ptrdiff_t; + using pointer = T*; + using reference = T&; + IteratorTemplate(TPtr x) : mObject(x) { } diff --git a/Sming/Wiring/WHashMap.h b/Sming/Wiring/WHashMap.h index 78bc60071d..18dbd4bbb2 100644 --- a/Sming/Wiring/WHashMap.h +++ b/Sming/Wiring/WHashMap.h @@ -107,10 +107,15 @@ template class HashMap using Element = BaseElement; using ElementConst = BaseElement; - template - class Iterator : public std::iterator> + template class Iterator { public: + using iterator_category = std::random_access_iterator_tag; + using value_type = BaseElement; + using difference_type = std::ptrdiff_t; + using pointer = BaseElement*; + using reference = BaseElement&; + using Map = typename std::conditional::type; using Value = typename std::conditional::type; diff --git a/Sming/Wiring/WVector.h b/Sming/Wiring/WVector.h index 6da2e68965..6d6856326c 100644 --- a/Sming/Wiring/WVector.h +++ b/Sming/Wiring/WVector.h @@ -33,9 +33,15 @@ template class Vector : public Countable public: using Comparer = int (*)(const Element& lhs, const Element& rhs); - template class Iterator : public std::iterator + template class Iterator { public: + using iterator_category = std::random_access_iterator_tag; + using value_type = Element; + using difference_type = std::ptrdiff_t; + using pointer = Element*; + using reference = Element&; + using V = typename std::conditional::type; using E = typename std::conditional::type;