Skip to content

Commit

Permalink
add operator+(int, iterator) overload
Browse files Browse the repository at this point in the history
  • Loading branch information
Crzyrndm authored and martinmoene committed Oct 16, 2023
1 parent e7734d8 commit fdaa014
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/nonstd/ring_span.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,12 @@ inline ring_iterator<RS,C> operator+( ring_iterator<RS,C> it, int i ) nsrs_noexc
it += i; return it;
}

template< class RS, bool C >
inline ring_iterator<RS,C> operator+( int i, ring_iterator<RS,C> it ) nsrs_noexcept
{
it += i; return it;
}

template< class RS, bool C >
inline ring_iterator<RS,C> operator-( ring_iterator<RS,C> it, int i ) nsrs_noexcept
{
Expand Down
1 change: 1 addition & 0 deletions test/ring-span.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,7 @@ CASE( "ring_iterator: Allows to offset iterator (+)" " [extension]" )
ring_span<int>::iterator pos = rs.begin();

EXPECT( *(pos + 2) == arr[2] );
EXPECT( *(2 + pos) == arr[2] );
#endif
}

Expand Down

0 comments on commit fdaa014

Please sign in to comment.