Skip to content

Commit

Permalink
Use of std::iterator is deprecated (#2642)
Browse files Browse the repository at this point in the history
Co-authored-by: mikee47 <[email protected]>
  • Loading branch information
mikee47 and mikee47 authored May 26, 2023
1 parent 47eddab commit 862bb32
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Sming/Components/FlashString
8 changes: 7 additions & 1 deletion Sming/Components/Storage/src/include/Storage/Iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@ namespace Storage
{
class Device;

class Iterator : public std::iterator<std::forward_iterator_tag, Partition>
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();
Expand Down
9 changes: 7 additions & 2 deletions Sming/Core/Data/LinkedObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,15 @@ class LinkedObject
template <typename ObjectType> class LinkedObjectTemplate : public LinkedObject
{
public:
template <typename T, typename TPtr, typename TRef>
class IteratorTemplate : public std::iterator<std::forward_iterator_tag, T>
template <typename T, typename TPtr, typename TRef> 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)
{
}
Expand Down
9 changes: 7 additions & 2 deletions Sming/Wiring/WHashMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,15 @@ template <typename K, typename V> class HashMap
using Element = BaseElement<false>;
using ElementConst = BaseElement<true>;

template <bool is_const>
class Iterator : public std::iterator<std::random_access_iterator_tag, BaseElement<is_const>>
template <bool is_const> class Iterator
{
public:
using iterator_category = std::random_access_iterator_tag;
using value_type = BaseElement<is_const>;
using difference_type = std::ptrdiff_t;
using pointer = BaseElement<is_const>*;
using reference = BaseElement<is_const>&;

using Map = typename std::conditional<is_const, const HashMap, HashMap>::type;
using Value = typename std::conditional<is_const, const V, V>::type;

Expand Down
8 changes: 7 additions & 1 deletion Sming/Wiring/WVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,15 @@ template <typename Element> class Vector : public Countable<Element>
public:
using Comparer = int (*)(const Element& lhs, const Element& rhs);

template <bool is_const> class Iterator : public std::iterator<std::random_access_iterator_tag, Element>
template <bool is_const> 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<is_const, const Vector, Vector>::type;
using E = typename std::conditional<is_const, const Element, Element>::type;

Expand Down

0 comments on commit 862bb32

Please sign in to comment.