Skip to content

Commit 553ffd3

Browse files
committed
Further simplify operator++ and operator--
Remove unnecessary clearing of to_increment_, clean up logic, remove separate overloads for advance_one()
1 parent 8b971fb commit 553ffd3

1 file changed

Lines changed: 7 additions & 19 deletions

File tree

‎include/beman/utf_view/to_utf_view.hpp‎

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -201,31 +201,19 @@ class exposition_only_to_utf_view_impl {
201201
/* PAPER */
202202

203203
constexpr void exposition_only_advance_one() // @*exposition only*@
204-
requires std::forward_iterator<exposition_only_iter>
205204
{
206-
if (buf_index_ + 1 < buf_last_) {
207-
++buf_index_;
208-
} else {
209-
std::advance(base(), to_increment_);
210-
to_increment_ = 0;
205+
++buf_index_;
206+
if (buf_index_ == buf_last_) {
207+
if constexpr (std::forward_iterator<exposition_only_iter>) {
208+
buf_index_ = 0;
209+
std::advance(base(), to_increment_);
210+
}
211211
if (base() != end()) {
212212
read();
213-
} else {
214-
buf_index_ = 0;
215213
}
216214
}
217215
}
218216

219-
constexpr void exposition_only_advance_one() // @*exposition only*@
220-
requires (!std::forward_iterator<exposition_only_iter>)
221-
{
222-
if (buf_index_ + 1 == buf_last_ && base() != end()) {
223-
read();
224-
} else {
225-
++buf_index_;
226-
}
227-
}
228-
229217
constexpr exposition_only_utf_iterator& operator++() requires(OrError)
230218
{
231219
if (!exposition_only_success()) {
@@ -262,7 +250,7 @@ class exposition_only_to_utf_view_impl {
262250
{
263251
if (!buf_index_)
264252
read_reverse();
265-
else if (buf_index_)
253+
else
266254
--buf_index_;
267255
return *this;
268256
}

0 commit comments

Comments
 (0)