Skip to content

Commit

Permalink
Remove the use of the deprecated std::iterator
Browse files Browse the repository at this point in the history
Using `std::iterator` as a base class has been deprecated since C++17, so this replaces it with the member types that it currently defines.

While I've done this change with C++17 in mind, this should be a fully-backwards compatible change with previous C++ standards.
  • Loading branch information
BenHetherington committed Sep 17, 2021
1 parent 33d15a8 commit 4324215
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
14 changes: 7 additions & 7 deletions include/rapidcheck/gen/detail/ShrinkValueIterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ namespace gen {
namespace detail {

template <typename Iterator>
class ShrinkValueIterator
: public std::iterator<
std::input_iterator_tag,
typename std::iterator_traits<Iterator>::value_type::ValueType,
std::ptrdiff_t,
typename std::iterator_traits<Iterator>::value_type::ValueType *,
typename std::iterator_traits<Iterator>::value_type::ValueType &&> {
class ShrinkValueIterator {
public:
using T = typename std::iterator_traits<Iterator>::value_type::ValueType;

using iterator_category = std::input_iterator_tag;
using value_type = T;
using difference_type = std::ptrdiff_t;
using pointer = T *;
using reference = T &&;

ShrinkValueIterator(Iterator it)
: m_it(it) {}

Expand Down
8 changes: 7 additions & 1 deletion include/rapidcheck/seq/SeqIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@ namespace seq {

/// STL iterator for `Seq`.
template <typename T>
class SeqIterator : public std::iterator<std::input_iterator_tag, T> {
class SeqIterator {
public:
using iterator_category = std::input_iterator_tag;
using value_type = T;
using difference_type = std::ptrdiff_t;
using pointer = T *;
using reference = T &;

/// Creates a new past-the-end `SeqIterator`.
SeqIterator() = default;

Expand Down

0 comments on commit 4324215

Please sign in to comment.