[all-commits] [llvm/llvm-project] bfdc56: [libc++] Fix copy-paste damage in `ranges::rotate_...

Stephan T. Lavavej via All-commits all-commits at lists.llvm.org
Wed Dec 6 02:29:24 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: bfdc562d0c6ff18ae3a8d618a2cb05c22a04898b
      https://github.com/llvm/llvm-project/commit/bfdc562d0c6ff18ae3a8d618a2cb05c22a04898b
  Author: Stephan T. Lavavej <stl at nuwen.net>
  Date:   2023-12-06 (Wed, 06 Dec 2023)

  Changed paths:
    M libcxx/include/__algorithm/ranges_rotate_copy.h
    M libcxx/test/std/algorithms/alg.modifying.operations/alg.rotate/ranges.rotate_copy.pass.cpp

  Log Message:
  -----------
  [libc++] Fix copy-paste damage in `ranges::rotate_copy` and its test (#74544)

Found while running libc++'s tests with MSVC's STL.

`ranges::rotate_copy` takes `forward_iterator`s as this test's comment
banner correctly depicts. However, this test had bogus assertions
expecting that `ranges::rotate_copy` would be constrained away for
not-quite-**bidi** iterators. @philnik777 confirmed that these were
copy-paste relics from the `ranges::reverse_copy` test.

I fixed this by replacing the assertions with the test types that aren't
quite **forward** iterators/ranges. Additionally, I noticed that the
top-level `test()` function was missing coverage with the weakest
possible `forward_iterator<int*>`.

This revealed that the product code in `ranges_rotate_copy.h` was
similarly damaged. In addition to fixing it by taking `forward_iterator`
and `forward_range` as depicted in the Standard, this drops the
inclusion of `<__iterator/reverse_iterator.h>` as this algorithm doesn't
need `std::__reverse_range`.




More information about the All-commits mailing list