diff --git a/accumulate.hpp b/accumulate.hpp index 0d43a20e..fb29853d 100644 --- a/accumulate.hpp +++ b/accumulate.hpp @@ -61,7 +61,7 @@ class iter::impl::Accumulator { sub_end_{std::move(sub_end)}, accumulate_func_(&accumulate_fun), // only get first value if not an end iterator - acc_val_{!(sub_iter_ != sub_end_) + acc_val_{(sub_iter_ == sub_end_) ? std::nullopt : std::make_optional(*sub_iter_)} {} diff --git a/batched.hpp b/batched.hpp index e5eadf13..1f198254 100644 --- a/batched.hpp +++ b/batched.hpp @@ -129,7 +129,7 @@ class iter::impl::Batcher { template bool operator==(const Iterator& other) const { return done() == other.done() - && (done() || !(sub_iter_ != other.sub_iter_)); + && (done() || (sub_iter_ == other.sub_iter_)); } DerefVec& operator*() { diff --git a/chunked.hpp b/chunked.hpp index 1d03b6e1..b1ae1c83 100644 --- a/chunked.hpp +++ b/chunked.hpp @@ -101,7 +101,7 @@ class iter::impl::Chunker { template bool operator==(const Iterator& other) const { return done() == other.done() - && (done() || !(sub_iter_ != other.sub_iter_)); + && (done() || (sub_iter_ == other.sub_iter_)); } DerefVec& operator*() { diff --git a/cycle.hpp b/cycle.hpp index 1d3ecaef..2fb0c0ce 100644 --- a/cycle.hpp +++ b/cycle.hpp @@ -63,7 +63,7 @@ class iter::impl::Cycler { Iterator& operator++() { ++sub_iter_; // reset to beginning upon reaching the sub_end_ - if (!(sub_iter_ != sub_end_)) { + if ((sub_iter_ == sub_end_)) { sub_iter_ = sub_begin_; } return *this; diff --git a/groupby.hpp b/groupby.hpp index 4f2fffb5..bd780305 100644 --- a/groupby.hpp +++ b/groupby.hpp @@ -154,7 +154,7 @@ class iter::impl::GroupProducer { } bool exhausted() const { - return !(sub_iter_ != sub_end_); + return (sub_iter_ == sub_end_); } typename Holder::reference get() { diff --git a/test/test_iteratoriterator.cpp b/test/test_iteratoriterator.cpp index dd2c4987..d69e4dd5 100644 --- a/test/test_iteratoriterator.cpp +++ b/test/test_iteratoriterator.cpp @@ -85,26 +85,25 @@ TEST_CASE("IteratorIterator supports mutable RandomAccessIterator operators", REQUIRE(&(*r2++) == &a[1]); REQUIRE(r == r2); auto test_const_or_not = [&itr](auto& a, auto& b) { - REQUIRE(!(b == a)); + REQUIRE((b != a)); REQUIRE(b == a + 2); REQUIRE(b == 2 + a); REQUIRE(b - 2 == a); REQUIRE(&a[2] == &b[0]); REQUIRE(b - a == 2); REQUIRE(a < b); - REQUIRE(!(a < a)); + REQUIRE((a >= a)); REQUIRE(b > a); - REQUIRE(!(a > a)); + REQUIRE((a = a)); REQUIRE(a <= b); - REQUIRE(!(b <= a)); + REQUIRE((b > a)); REQUIRE(a <= a); REQUIRE(b >= a); - REQUIRE(!(a >= b)); + REQUIRE((a < b)); REQUIRE(a >= a); // InputIterator: REQUIRE(b != a); - REQUIRE(!(a != a)); REQUIRE(&(*a) != &(*b)); REQUIRE(&(a->value) == &(*a).value);