From fab8a01048fc6cfcee7e89884a5af31385189c63 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Thu, 18 Jan 2024 15:24:00 +0100 Subject: [PATCH] refactor: Fix binary operator+ for prevector iterators --- src/prevector.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/prevector.h b/src/prevector.h index f643a0d591246..8b07d8c289d02 100644 --- a/src/prevector.h +++ b/src/prevector.h @@ -65,6 +65,7 @@ class prevector { iterator operator--(int) { iterator copy(*this); --(*this); return copy; } difference_type friend operator-(iterator a, iterator b) { return (&(*a) - &(*b)); } iterator operator+(size_type n) const { return iterator(ptr + n); } + iterator friend operator+(size_type n, iterator x) { return x + n; } iterator& operator+=(size_type n) { ptr += n; return *this; } iterator operator-(size_type n) const { return iterator(ptr - n); } iterator& operator-=(size_type n) { ptr -= n; return *this; } @@ -116,6 +117,7 @@ class prevector { const_iterator operator--(int) { const_iterator copy(*this); --(*this); return copy; } difference_type friend operator-(const_iterator a, const_iterator b) { return (&(*a) - &(*b)); } const_iterator operator+(size_type n) const { return const_iterator(ptr + n); } + const_iterator friend operator+(size_type n, const_iterator x) { return x + n; } const_iterator& operator+=(size_type n) { ptr += n; return *this; } const_iterator operator-(size_type n) const { return const_iterator(ptr - n); } const_iterator& operator-=(size_type n) { ptr -= n; return *this; }