Inheriting std::iterator is deprecated in c++17.

Boost's iterator.hpp is deprecated, too. Therefore get rid of all of that and replace inheritance by lifting std::iterator's members into the derived class.

Signed-off-by: Daniela Engert <dani@ngrt.de>
This commit is contained in:
Daniela Engert
2017-12-27 09:20:39 +01:00
parent 218dc4baf1
commit e16f2de233
4 changed files with 67 additions and 43 deletions

View File

@ -16,8 +16,13 @@ struct new_random_access
{};
struct new_iterator
: public std::iterator< new_random_access, int >
{
typedef new_random_access iterator_category;
typedef int value_type;
typedef std::ptrdiff_t difference_type;
typedef int* pointer;
typedef int& reference;
int& operator*() const { return *m_x; }
new_iterator& operator++() { return *this; }
new_iterator operator++(int) { return *this; }
@ -36,8 +41,13 @@ struct new_iterator
new_iterator operator+(std::ptrdiff_t, new_iterator x) { return x; }
struct old_iterator
: public std::iterator<std::random_access_iterator_tag, int>
{
typedef std::random_access_iterator_tag iterator_category;
typedef int value_type;
typedef std::ptrdiff_t difference_type;
typedef int* pointer;
typedef int& reference;
int& operator*() const { return *m_x; }
old_iterator& operator++() { return *this; }
old_iterator operator++(int) { return *this; }