Updated iterator class

updated the code which was using the std::iterator class, which has been marked as deprecated in the C++17 standard

Signed-off-by: ABHISHEK ANAND <abhishekabhishek1012@gmail.com>
This commit is contained in:
ABHISHEK ANAND 2023-03-28 00:32:56 +05:30
parent 45dcd50242
commit f55ee0e8bb
4 changed files with 41 additions and 15 deletions

View File

@ -56,9 +56,15 @@ class BigEndianSpan {
absl::Span<ByteType> bytes_; absl::Span<ByteType> bytes_;
}; };
class iterator class iterator {
: public std::iterator<std::input_iterator_tag, value_type> {
public: public:
using iterator_category = std::input_iterator_tag;
using value_type = BigEndianSpan::value_type;
using difference_type = std::ptrdiff_t;
using pointer = value_type*;
using reference = value_type&;
value_type operator*() const { return value_type(bytes_); } value_type operator*() const { return value_type(bytes_); }
bool operator==(const iterator& other) const { bool operator==(const iterator& other) const {

View File

@ -34,9 +34,14 @@ class SegbitsFileReader {
absl::string_view bit_; absl::string_view bit_;
}; };
class iterator class iterator {
: public std::iterator<std::input_iterator_tag, value_type> { public:
public: using iterator_category = std::input_iterator_tag;
using value_type = SegbitsFileReader::value_type;
using difference_type = std::ptrdiff_t;
using pointer = value_type*;
using reference = value_type&;
iterator& operator++(); iterator& operator++();
bool operator==(iterator other) const { bool operator==(iterator other) const {

View File

@ -33,9 +33,14 @@ class BitstreamReader {
// Implements an iterator over the words grouped in configuration // Implements an iterator over the words grouped in configuration
// packets. // packets.
class iterator class iterator {
: public std::iterator<std::input_iterator_tag, value_type> { public:
public: using iterator_category = std::input_iterator_tag;
using value_type = BitstreamReader::value_type;
using difference_type = std::ptrdiff_t;
using pointer = value_type*;
using reference = value_type&;
iterator& operator++(); iterator& operator++();
bool operator==(const iterator& other) const; bool operator==(const iterator& other) const;

View File

@ -51,9 +51,14 @@ class BitstreamWriter {
typedef absl::Span<const uint32_t>::iterator data_iterator_t; typedef absl::Span<const uint32_t>::iterator data_iterator_t;
using itr_value_type = uint32_t; using itr_value_type = uint32_t;
class packet_iterator class packet_iterator {
: public std::iterator<std::input_iterator_tag, itr_value_type> { public:
public: using iterator_category = std::input_iterator_tag;
using value_type = BitstreamWriter::itr_value_type;
using difference_type = std::ptrdiff_t;
using pointer = value_type*;
using reference = value_type&;
packet_iterator& operator++(); packet_iterator& operator++();
bool operator==(const packet_iterator& other) const; bool operator==(const packet_iterator& other) const;
@ -76,7 +81,7 @@ class BitstreamWriter {
data_iterator_t itr_data); data_iterator_t itr_data);
private: private:
friend iterator; friend class iterator;
friend BitstreamWriter; friend BitstreamWriter;
// Data iterators // Data iterators
@ -89,9 +94,14 @@ class BitstreamWriter {
packet_; packet_;
}; };
class iterator class iterator {
: public std::iterator<std::input_iterator_tag, itr_value_type> { public:
public: using iterator_category = std::input_iterator_tag;
using value_type = BitstreamWriter::itr_value_type;
using difference_type = std::ptrdiff_t;
using pointer = value_type*;
using reference = value_type&;
iterator& operator++(); iterator& operator++();
bool operator==(const iterator& other) const; bool operator==(const iterator& other) const;