Skip to content

Commit 42cc095

Browse files
Crzyrndmmartinmoene
authored andcommitted
add operator+(int, iterator) overload (#30, #31, thanks @Crzyrndm)
1 parent 2c6ae83 commit 42cc095

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

include/nonstd/ring_span.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,6 +1104,12 @@ inline ring_iterator<RS,C> operator+( ring_iterator<RS,C> it, int i ) nsrs_noexc
11041104
it += i; return it;
11051105
}
11061106

1107+
template< class RS, bool C >
1108+
inline ring_iterator<RS,C> operator+( int i, ring_iterator<RS,C> it ) nsrs_noexcept
1109+
{
1110+
it += i; return it;
1111+
}
1112+
11071113
template< class RS, bool C >
11081114
inline ring_iterator<RS,C> operator-( ring_iterator<RS,C> it, int i ) nsrs_noexcept
11091115
{

test/ring-span.t.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,7 @@ CASE( "ring_iterator: Allows to offset iterator (+)" " [extension]" )
944944
ring_span<int>::iterator pos = rs.begin();
945945

946946
EXPECT( *(pos + 2) == arr[2] );
947+
EXPECT( *(2 + pos) == arr[2] );
947948
#endif
948949
}
949950

0 commit comments

Comments
 (0)