[libcxx-commits] [PATCH] D125752: [libc++] Implement ranges::reverse

Nikolas Klauser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed May 18 04:21:10 PDT 2022


philnik added inline comments.


================
Comment at: libcxx/include/__algorithm/ranges_reverse.h:40
+
+      while (__first < --__end) {
+        ranges::iter_swap(__first, __end);
----------------
var-const wrote:
> Question: how is this loop more efficient than the non-random access iterator version?
In the forward variant we have to check that `__first != __end` and `__first != --__end`. In the random-access version we can just check that `__first < --__end`, so we do half the comparisons.


================
Comment at: libcxx/test/support/almost_satisfies_types.h:142
 
+class BidirectionalIteratorNotDerivedFrom {
+public:
----------------
var-const wrote:
> Nit: make it a `struct`, so that it won't be necessary to specify `public`?
I made everything else in this file a class and then made it `public`. I'd rather keep it that way for consistency.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125752



More information about the libcxx-commits mailing list