forked from Ferdi265/cxx-ring-buffer
ring-buffer-iterator: fix postfix increment/decrement
this silently did the wrong thing on g++ (precedence of postfix ++/--) and didn't compile on clang++. The correct solution is to prefix-increment, which has no precedence issues and calls the correct function. Postfix-increment with correct precedence would have resulted in a stack overflow anyway.
This commit is contained in:
@ -61,7 +61,7 @@ public:
|
||||
}
|
||||
CONSTEXPR ring_buffer_iterator operator++(int) NOEXCEPT {
|
||||
ring_buffer_iterator old = *this;
|
||||
*this++;
|
||||
++*this;
|
||||
return old;
|
||||
}
|
||||
CONSTEXPR ring_buffer_iterator& operator--() NOEXCEPT {
|
||||
@ -70,7 +70,7 @@ public:
|
||||
}
|
||||
CONSTEXPR ring_buffer_iterator operator--(int) NOEXCEPT {
|
||||
ring_buffer_iterator old = *this;
|
||||
*this--;
|
||||
--*this;
|
||||
return old;
|
||||
}
|
||||
|
||||
@ -161,7 +161,7 @@ public:
|
||||
}
|
||||
CONSTEXPR ring_buffer_const_iterator operator++(int) NOEXCEPT {
|
||||
ring_buffer_const_iterator old = *this;
|
||||
*this++;
|
||||
++*this;
|
||||
return old;
|
||||
}
|
||||
CONSTEXPR ring_buffer_const_iterator& operator--() NOEXCEPT {
|
||||
@ -170,7 +170,7 @@ public:
|
||||
}
|
||||
CONSTEXPR ring_buffer_const_iterator operator--(int) NOEXCEPT {
|
||||
ring_buffer_const_iterator old = *this;
|
||||
*this--;
|
||||
--*this;
|
||||
return old;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user