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

Konstantin Varlamov via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jul 18 20:26:19 PDT 2022


var-const added inline comments.


================
Comment at: libcxx/include/__algorithm/iterator_operations.h:92
+                          typename iterator_traits<__uncvref_t<_Iter> >::difference_type __n = 1){
+    return std::next(std::forward<_Iter>(__it), __n);
+  }
----------------
This is copied from https://reviews.llvm.org/D129796.


================
Comment at: libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/ranges_stable_partition.pass.cpp:236
+      }
+    }
+  }
----------------
huixie90 wrote:
> 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
> 
I'd prefer to do these checks en masse: https://reviews.llvm.org/D130057


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