[llvm] [ADT] Add `llvm::conditionally_reverse()` iterator (PR #171040)
Jakub Kuderski via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 7 10:51:20 PST 2025
================
@@ -1415,6 +1415,18 @@ template <typename ContainerTy> auto make_second_range(ContainerTy &&c) {
});
}
+/// Return a range that conditionally reverses \p C. The collection is iterated
+/// in reverse if \p Reverse is true (otherwise, it is iterated forwards).
+template <typename ContainerTy>
+[[nodiscard]] auto conditionally_reverse(ContainerTy &&C, bool Reverse) {
+ using ForwardIteratorT = decltype(C.begin());
----------------
kuhar wrote:
Use adl_begin.
I think there's also some utility for this already like `detail::IterOfRange<RangeT>` and `ValueOfRange` -- could we use those?
https://github.com/llvm/llvm-project/pull/171040
More information about the llvm-commits
mailing list