Skip to content

Commit

Permalink
Stop using the std::iterator deprecated in C++17.
Browse files Browse the repository at this point in the history
  • Loading branch information
foxik committed Sep 12, 2023
1 parent 6dea4f3 commit d00b2b3
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 10 deletions.
5 changes: 3 additions & 2 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Version 3.3.1-dev
-----------------
Version 3.3.1 [12 Sep 2023]
---------------------------
- Stop using the std::iterator deprecated in C++17.


Version 3.3.0 [13 Sep 2022]
Expand Down
14 changes: 12 additions & 2 deletions gen/template/utf16.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,13 @@ void utf16::decode(const std::u16string& str, std::u32string& decoded) {
decode(str.c_str(), decoded);
}

class utf16::string_decoder::iterator : public std::iterator<std::input_iterator_tag, char32_t> {
class utf16::string_decoder::iterator {
public:
using iterator_category = std::input_iterator_tag;
using value_type = char32_t;
using difference_type = ptrdiff_t;
using pointer = char32_t*;
using reference = char32_t&;
iterator(const char16_t* str) : codepoint(0), next(str) { operator++(); }
iterator(const iterator& it) : codepoint(it.codepoint), next(it.next) {}
iterator& operator++() { if (next) { codepoint = decode(next); if (!codepoint) next = nullptr; } return *this; }
Expand Down Expand Up @@ -144,8 +149,13 @@ utf16::string_decoder utf16::decoder(const std::u16string& str) {
return string_decoder(str.c_str());
}

class utf16::buffer_decoder::iterator : public std::iterator<std::input_iterator_tag, char32_t> {
class utf16::buffer_decoder::iterator {
public:
using iterator_category = std::input_iterator_tag;
using value_type = char32_t;
using difference_type = ptrdiff_t;
using pointer = char32_t*;
using reference = char32_t&;
iterator(const char16_t* str, size_t len) : codepoint(0), next(str), len(len) { operator++(); }
iterator(const iterator& it) : codepoint(it.codepoint), next(it.next), len(it.len) {}
iterator& operator++() { if (!len) next = nullptr; if (next) codepoint = decode(next, len); return *this; }
Expand Down
14 changes: 12 additions & 2 deletions gen/template/utf8.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,13 @@ void utf8::decode(const std::string& str, std::u32string& decoded) {
decode(str.c_str(), decoded);
}

class utf8::string_decoder::iterator : public std::iterator<std::input_iterator_tag, char32_t> {
class utf8::string_decoder::iterator {
public:
using iterator_category = std::input_iterator_tag;
using value_type = char32_t;
using difference_type = ptrdiff_t;
using pointer = char32_t*;
using reference = char32_t&;
iterator(const char* str) : codepoint(0), next(str) { operator++(); }
iterator(const iterator& it) : codepoint(it.codepoint), next(it.next) {}
iterator& operator++() { if (next) { codepoint = decode(next); if (!codepoint) next = nullptr; } return *this; }
Expand Down Expand Up @@ -176,8 +181,13 @@ utf8::string_decoder utf8::decoder(const std::string& str) {
return string_decoder(str.c_str());
}

class utf8::buffer_decoder::iterator : public std::iterator<std::input_iterator_tag, char32_t> {
class utf8::buffer_decoder::iterator {
public:
using iterator_category = std::input_iterator_tag;
using value_type = char32_t;
using difference_type = ptrdiff_t;
using pointer = char32_t*;
using reference = char32_t&;
iterator(const char* str, size_t len) : codepoint(0), next(str), len(len) { operator++(); }
iterator(const iterator& it) : codepoint(it.codepoint), next(it.next), len(it.len) {}
iterator& operator++() { if (!len) next = nullptr; if (next) codepoint = decode(next, len); return *this; }
Expand Down
14 changes: 12 additions & 2 deletions unilib/utf16.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,13 @@ void utf16::decode(const std::u16string& str, std::u32string& decoded) {
decode(str.c_str(), decoded);
}

class utf16::string_decoder::iterator : public std::iterator<std::input_iterator_tag, char32_t> {
class utf16::string_decoder::iterator {
public:
using iterator_category = std::input_iterator_tag;
using value_type = char32_t;
using difference_type = ptrdiff_t;
using pointer = char32_t*;
using reference = char32_t&;
iterator(const char16_t* str) : codepoint(0), next(str) { operator++(); }
iterator(const iterator& it) : codepoint(it.codepoint), next(it.next) {}
iterator& operator++() { if (next) { codepoint = decode(next); if (!codepoint) next = nullptr; } return *this; }
Expand Down Expand Up @@ -144,8 +149,13 @@ utf16::string_decoder utf16::decoder(const std::u16string& str) {
return string_decoder(str.c_str());
}

class utf16::buffer_decoder::iterator : public std::iterator<std::input_iterator_tag, char32_t> {
class utf16::buffer_decoder::iterator {
public:
using iterator_category = std::input_iterator_tag;
using value_type = char32_t;
using difference_type = ptrdiff_t;
using pointer = char32_t*;
using reference = char32_t&;
iterator(const char16_t* str, size_t len) : codepoint(0), next(str), len(len) { operator++(); }
iterator(const iterator& it) : codepoint(it.codepoint), next(it.next), len(it.len) {}
iterator& operator++() { if (!len) next = nullptr; if (next) codepoint = decode(next, len); return *this; }
Expand Down
14 changes: 12 additions & 2 deletions unilib/utf8.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,13 @@ void utf8::decode(const std::string& str, std::u32string& decoded) {
decode(str.c_str(), decoded);
}

class utf8::string_decoder::iterator : public std::iterator<std::input_iterator_tag, char32_t> {
class utf8::string_decoder::iterator {
public:
using iterator_category = std::input_iterator_tag;
using value_type = char32_t;
using difference_type = ptrdiff_t;
using pointer = char32_t*;
using reference = char32_t&;
iterator(const char* str) : codepoint(0), next(str) { operator++(); }
iterator(const iterator& it) : codepoint(it.codepoint), next(it.next) {}
iterator& operator++() { if (next) { codepoint = decode(next); if (!codepoint) next = nullptr; } return *this; }
Expand Down Expand Up @@ -176,8 +181,13 @@ utf8::string_decoder utf8::decoder(const std::string& str) {
return string_decoder(str.c_str());
}

class utf8::buffer_decoder::iterator : public std::iterator<std::input_iterator_tag, char32_t> {
class utf8::buffer_decoder::iterator {
public:
using iterator_category = std::input_iterator_tag;
using value_type = char32_t;
using difference_type = ptrdiff_t;
using pointer = char32_t*;
using reference = char32_t&;
iterator(const char* str, size_t len) : codepoint(0), next(str), len(len) { operator++(); }
iterator(const iterator& it) : codepoint(it.codepoint), next(it.next), len(it.len) {}
iterator& operator++() { if (!len) next = nullptr; if (next) codepoint = decode(next, len); return *this; }
Expand Down

0 comments on commit d00b2b3

Please sign in to comment.