Skip to content

Commit fab8a01

Browse files
author
MarcoFalke
committed
refactor: Fix binary operator+ for prevector iterators
1 parent fa44a60 commit fab8a01

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/prevector.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class prevector {
6565
iterator operator--(int) { iterator copy(*this); --(*this); return copy; }
6666
difference_type friend operator-(iterator a, iterator b) { return (&(*a) - &(*b)); }
6767
iterator operator+(size_type n) const { return iterator(ptr + n); }
68+
iterator friend operator+(size_type n, iterator x) { return x + n; }
6869
iterator& operator+=(size_type n) { ptr += n; return *this; }
6970
iterator operator-(size_type n) const { return iterator(ptr - n); }
7071
iterator& operator-=(size_type n) { ptr -= n; return *this; }
@@ -116,6 +117,7 @@ class prevector {
116117
const_iterator operator--(int) { const_iterator copy(*this); --(*this); return copy; }
117118
difference_type friend operator-(const_iterator a, const_iterator b) { return (&(*a) - &(*b)); }
118119
const_iterator operator+(size_type n) const { return const_iterator(ptr + n); }
120+
const_iterator friend operator+(size_type n, const_iterator x) { return x + n; }
119121
const_iterator& operator+=(size_type n) { ptr += n; return *this; }
120122
const_iterator operator-(size_type n) const { return const_iterator(ptr - n); }
121123
const_iterator& operator-=(size_type n) { ptr -= n; return *this; }

0 commit comments

Comments
 (0)