Skip to content

Commit

Permalink
Update wrap_iter operators to use std::next and std::prev
Browse files Browse the repository at this point in the history
Replaced manual increment and decrement logic with `std::next` and `std::prev` for improved clarity and safety. Also corrected the return type of the subtraction operator.
  • Loading branch information
beached committed Jan 26, 2025
1 parent e69d94b commit 67c180b
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions include/daw/wrap_iter.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ namespace daw {
}

constexpr wrap_iter &operator++( ) noexcept {
DAW_UNSAFE_BUFFER_FUNC_START
++i;
DAW_UNSAFE_BUFFER_FUNC_STOP
i = std::next( i );
return *this;
}

Expand All @@ -65,9 +63,7 @@ namespace daw {
}

constexpr wrap_iter &operator--( ) noexcept {
DAW_UNSAFE_BUFFER_FUNC_START
--i;
DAW_UNSAFE_BUFFER_FUNC_STOP
i = std::prev( i );
return *this;
}

Expand Down Expand Up @@ -106,7 +102,7 @@ namespace daw {
}

// clang-format off
constexpr auto operator<=> ( wrap_iter const &rhs ) const noexcept {
constexpr auto operator<=>( wrap_iter const &rhs ) const noexcept {
return base( ) <=> rhs.base( );
}
// clang-format on
Expand All @@ -121,7 +117,7 @@ namespace daw {
};

template<typename Iterator1, class Iterator2, typename Tag>
constexpr bool operator-( wrap_iter<Iterator1, Tag> const &x,
constexpr auto operator-( wrap_iter<Iterator1, Tag> const &x,
wrap_iter<Iterator2, Tag> const &y ) noexcept {
return x.base( ) - y.base( );
}
Expand Down

0 comments on commit 67c180b

Please sign in to comment.