Skip to content

Commit ea7a13a

Browse files
committed
fix forward_iterator multpass-guarantee test
1 parent 69f1518 commit ea7a13a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tests/unittests/std_interoperability.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,10 +507,12 @@ TEST_CASE("Collection and iterator concepts", "[collection][container][iterator]
507507
coll.create();
508508
auto i = coll.begin();
509509
auto j = coll.begin();
510+
// multi-pass guarantee
510511
REQUIRE(i == j);
511512
REQUIRE(++i == ++j);
512513
i = coll.begin();
513-
REQUIRE(((void)[](auto x) { ++x; }(i), *i) == *i);
514+
REQUIRE(*i == ((void)[](auto x) { ++x; }(i), *i)); // iterating copy doesn't cause side effects that affect the
515+
// original iterator
514516
}
515517
// const_iterator
516518
STATIC_REQUIRE(std::forward_iterator<const_iterator>);
@@ -520,10 +522,12 @@ TEST_CASE("Collection and iterator concepts", "[collection][container][iterator]
520522
coll.create();
521523
auto i = coll.cbegin();
522524
auto j = coll.cbegin();
525+
// multi-pass guarantee
523526
REQUIRE(i == j);
524527
REQUIRE(++i == ++j);
525528
i = coll.cbegin();
526-
REQUIRE(((void)[](auto x) { ++x; }(i), *i) == *i);
529+
REQUIRE(*i == ((void)[](auto x) { ++x; }(i), *i)); // iterating copy doesn't cause side effects that affect the
530+
// original iterator
527531
}
528532
}
529533

0 commit comments

Comments
 (0)