[libcxx-commits] [PATCH] D129624: [libc++][ranges] Implement `ranges::{, stable_}partition`.

Hui via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jul 18 02:19:26 PDT 2022


huixie90 accepted this revision.
huixie90 added a comment.

The algorithm LGTM.  Regarding testing, I still prefer to have extra tests to verify `iter_move` and/or `iter_swap` is correctly used



================
Comment at: libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/ranges_stable_partition.pass.cpp:236
+      }
+    }
+  }
----------------
as these algorithms involves `iter_move`, I suggests to add tests to verify the outputs before we can figure out an automated way to catch in via a compile-time tests. so here , we could have 
```
std::array<MoveOnly, N> a{...];
ProxyRange r{a};
std::ranges::partition(r);
// verify that the original `a` is partitioned as the expected result
```

(actually even without verifying the result, the compiler would catch `std::move(*it)` because  `std::move(*it)` would copy the `MoveOnly` for `Proxy<MoveOnly&>&&` and `MoveOnly` is not copyable



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129624



More information about the libcxx-commits mailing list