@@ -212,7 +212,7 @@ namespace itertools {
212212 */
213213 const_iterator operator ++(int ) noexcept {
214214 const_iterator tmp = *this ;
215- ++* this ;
215+ pos += step ;
216216 return tmp;
217217 }
218218
@@ -231,7 +231,7 @@ namespace itertools {
231231 */
232232 const_iterator operator --(int ) noexcept {
233233 const_iterator tmp = *this ;
234- --* this ;
234+ pos -= step ;
235235 return tmp;
236236 }
237237
@@ -242,7 +242,9 @@ namespace itertools {
242242 * @return If the step size is > 0, it returns the result of a three-way comparison of their current values.
243243 * Otherwise, it three-way compares their negative values.
244244 */
245- std::strong_ordering operator <=>(const_iterator const &rhs) const noexcept { return (step > 0 ? pos <=> rhs.pos : -pos <=> -rhs.pos ); }
245+ [[nodiscard]] std::strong_ordering operator <=>(const_iterator const &rhs) const noexcept {
246+ return (step > 0 ? pos <=> rhs.pos : -pos <=> -rhs.pos );
247+ }
246248
247249 /* *
248250 * @brief Equal-to operator for two iterators.
@@ -287,9 +289,7 @@ namespace itertools {
287289 * @param it Iterator.
288290 * @return Copy of the given iterator with its current value increased by the step size multiplied by \f$ n \f$.
289291 */
290- [[nodiscard]] friend const_iterator operator +(difference_type n, const_iterator it) noexcept {
291- return {.pos = it.pos + n * it.step , .step = it.step };
292- }
292+ [[nodiscard]] friend const_iterator operator +(difference_type n, const_iterator it) noexcept { return it + n; }
293293
294294 /* *
295295 * @brief Subtraction assignment operator.
@@ -321,7 +321,8 @@ namespace itertools {
321321 * @return Current value increased by the step size multiplied by \f$ n \f$.
322322 */
323323 [[nodiscard]] value_type operator [](difference_type n) const noexcept { return pos + n * step; }
324- };
324+
325+ }; // end struct const_iterator
325326
326327 // / Reverse const iterator type for itertools::range.
327328 using const_reverse_iterator = std::reverse_iterator<range::const_iterator>;
0 commit comments