[libcxx-commits] [PATCH] D117240: [libc++] Fix bug in ranges::advance and refactor the tests

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jan 13 11:06:06 PST 2022


ldionne added inline comments.


================
Comment at: libcxx/include/__iterator/advance.h:80-91
+  static constexpr bool __magnitude_geq(_Tp __a, _Tp __b) {
+    if (__a < 0)
+      if (__b < 0)
+        return __a <= __b;
+      else
+        return __a + __b <= 0;
+    else
----------------
I'm open to bikeshedding this implementation.

AFAICT, this implementation is a general-purpose magnitude->= implementation that doesn't suffer from overflow (I think).

We technically don't need something as general, but my preference would be to keep it general unless we have a noticeably more performant implementation, because keeping it general makes it easier to understand.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117240



More information about the libcxx-commits mailing list