[libcxx-commits] [PATCH] D127194: [libc++][ranges] Implement `ranges::is_permutation`

Konstantin Varlamov via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Jul 29 23:20:20 PDT 2022


var-const updated this revision to Diff 448774.
var-const added a comment.

Changes to `is_permutation.h`:

- refactor out the common part of `__is_partition` overloads taking 3 and 4 iterators;
- rename `__is_partition` to `__is_partition3` and `__is_partition4` depending on the number of iterators;
- to optimize `__is_partition` for constant-time `distance`, replace the existing tag dispatch based on iterator category with a custom trait. This works with ranges and covers more cases in C++20 mode;
- fix the bug in the optimization above which would prevent it from being selected by overload resolution (incorrect iterator types in the signature) unless all iterator types are the same;
- use `_IterOps` in `__is_partition`;
- other miscellaneous cleanup.

Changes to the tests:

- check SFINAE on the predicate;
- add tests for a custom predicate;
- add tests for a custom projection;
- add more complexity tests and use `counting_{projection,predicate}`;
- add a couple more test cases.

Also address the existing feedback and rebase on `main`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127194/new/

https://reviews.llvm.org/D127194

Files:
  libcxx/docs/Status/RangesAlgorithms.csv
  libcxx/include/CMakeLists.txt
  libcxx/include/__algorithm/is_permutation.h
  libcxx/include/__algorithm/ranges_is_permutation.h
  libcxx/include/__iterator/iterator_traits.h
  libcxx/include/algorithm
  libcxx/include/module.modulemap.in
  libcxx/test/libcxx/algorithms/ranges_robust_against_copying_comparators.pass.cpp
  libcxx/test/libcxx/algorithms/ranges_robust_against_copying_projections.pass.cpp
  libcxx/test/libcxx/private_headers.verify.cpp
  libcxx/test/std/algorithms/alg.nonmodifying/alg.is_permutation/ranges.is_permutation.pass.cpp
  libcxx/test/std/algorithms/ranges_robust_against_differing_projections.pass.cpp
  libcxx/test/std/algorithms/ranges_robust_against_nonbool_predicates.pass.cpp
  libcxx/test/std/algorithms/ranges_robust_against_omitting_invoke.pass.cpp
  libcxx/test/std/algorithms/ranges_robust_against_proxy_iterators.pass.cpp
  libcxx/test/std/library/description/conventions/customization.point.object/niebloid.compile.pass.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127194.448774.patch
Type: text/x-patch
Size: 42334 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220730/0fd91c95/attachment-0001.bin>


More information about the libcxx-commits mailing list