aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/utils/algorithm.h
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2020-07-13 13:50:56 +0200
committerEike Ziller <eike.ziller@qt.io>2020-07-14 07:07:56 +0000
commit6ac8bf2f0a48e49dc145a9b6f2a9cfb460fd4f76 (patch)
treea0409e7d089db127295a98cab1f5c368155463dc /src/libs/utils/algorithm.h
parenta066bfd170979634e58094804358088a1203cbe2 (diff)
Algorithm: Do not derive from std::iterator
MSVC throws warnings that this is deprecated. Change-Id: I010c54a923f395a04a4c84cfcd01848a42752e2e Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/libs/utils/algorithm.h')
-rw-r--r--src/libs/utils/algorithm.h74
1 files changed, 39 insertions, 35 deletions
diff --git a/src/libs/utils/algorithm.h b/src/libs/utils/algorithm.h
index 5a3c4edee66..e5b4396f24b 100644
--- a/src/libs/utils/algorithm.h
+++ b/src/libs/utils/algorithm.h
@@ -566,52 +566,56 @@ namespace {
// SetInsertIterator, straight from the standard for insert_iterator
// just without the additional parameter to insert
-template <class Container>
- class SetInsertIterator :
- public std::iterator<std::output_iterator_tag,void,void,void,void>
+template<class Container>
+class SetInsertIterator
{
protected:
Container *container;
public:
- using container_type = Container;
- explicit SetInsertIterator (Container &x)
- : container(&x) {}
- SetInsertIterator<Container> &operator=(const typename Container::value_type &value)
- { container->insert(value); return *this; }
- SetInsertIterator<Container> &operator= (typename Container::value_type &&value)
- { container->insert(std::move(value)); return *this; }
- SetInsertIterator<Container >&operator*()
- { return *this; }
- SetInsertIterator<Container> &operator++()
- { return *this; }
- SetInsertIterator<Container> operator++(int)
- { return *this; }
+ using iterator_category = std::output_iterator_tag;
+ using container_type = Container;
+ explicit SetInsertIterator(Container &x)
+ : container(&x)
+ {}
+ SetInsertIterator<Container> &operator=(const typename Container::value_type &value)
+ {
+ container->insert(value);
+ return *this;
+ }
+ SetInsertIterator<Container> &operator=(typename Container::value_type &&value)
+ {
+ container->insert(std::move(value));
+ return *this;
+ }
+ SetInsertIterator<Container> &operator*() { return *this; }
+ SetInsertIterator<Container> &operator++() { return *this; }
+ SetInsertIterator<Container> operator++(int) { return *this; }
};
// for QMap / QHash, inserting a std::pair / QPair
-template <class Container>
- class MapInsertIterator :
- public std::iterator<std::output_iterator_tag,void,void,void,void>
- {
- protected:
+template<class Container>
+class MapInsertIterator
+{
+protected:
Container *container;
- public:
+public:
+ using iterator_category = std::output_iterator_tag;
using container_type = Container;
- explicit MapInsertIterator (Container &x)
- : container(&x) {}
- MapInsertIterator<Container> &operator=(const std::pair<const typename Container::key_type, typename Container::mapped_type> &value)
- { container->insert(value.first, value.second); return *this; }
- MapInsertIterator<Container> &operator=(const QPair<typename Container::key_type, typename Container::mapped_type> &value)
- { container->insert(value.first, value.second); return *this; }
- MapInsertIterator<Container >&operator*()
- { return *this; }
- MapInsertIterator<Container> &operator++()
- { return *this; }
- MapInsertIterator<Container> operator++(int)
- { return *this; }
- };
+ explicit MapInsertIterator(Container &x)
+ : container(&x)
+ {}
+ MapInsertIterator<Container> &operator=(
+ const std::pair<const typename Container::key_type, typename Container::mapped_type> &value)
+ { container->insert(value.first, value.second); return *this; }
+ MapInsertIterator<Container> &operator=(
+ const QPair<typename Container::key_type, typename Container::mapped_type> &value)
+ { container->insert(value.first, value.second); return *this; }
+ MapInsertIterator<Container> &operator*() { return *this; }
+ MapInsertIterator<Container> &operator++() { return *this; }
+ MapInsertIterator<Container> operator++(int) { return *this; }
+};
// inserter helper function, returns a std::back_inserter for most containers
// and is overloaded for QSet<> and other containers without push_back, returning custom inserters