Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of std::iterator is deprecated #2642

Merged
merged 1 commit into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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