Skip to content

Commit 69e3ff6

Browse files
authored
[libc++] Fix ranges_rotate.pass.cpp complexity checks (#158144)
The complexity is "at most N swaps" _for each invocation of `rotate`_, but the tests currently assert that the total number of swaps for N calls is at most N. The standard allows that to be N squared, so the test is either requiring more than the standard (and the comment in the test) promises, or somebody just forgot to reset the counter on each iteration.
1 parent 6040c00 commit 69e3ff6

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

libcxx/test/std/algorithms/alg.modifying.operations/alg.rotate/ranges_rotate.pass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ constexpr bool test() {
173173
auto end = adl::Iterator::TrackSwaps(in.data() + in.size(), swaps);
174174

175175
for (std::size_t mid = 0; mid != input.size(); ++mid) {
176+
swaps = 0;
176177
std::ranges::rotate(begin, begin + mid, end);
177178
assert(swaps <= expected);
178179
}
@@ -186,6 +187,7 @@ constexpr bool test() {
186187
auto range = std::ranges::subrange(begin, end);
187188

188189
for (std::size_t mid = 0; mid != input.size(); ++mid) {
190+
swaps = 0;
189191
std::ranges::rotate(range, begin + mid);
190192
assert(swaps <= expected);
191193
}

0 commit comments

Comments
 (0)