[libcxx-commits] [PATCH] D124079: [libc++] Implement ranges::find_end, ranges::search{, _n}

Hui via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jul 6 13:41:44 PDT 2022


huixie90 added inline comments.


================
Comment at: libcxx/include/__algorithm/ranges_search.h:99
+      auto __size2 = ranges::size(__range2);
+      if (__size2 <= 0)
+        return {__first1, __first1};
----------------
why `<=`? as the size is unsigned, is it just ==0?


================
Comment at: libcxx/include/__iterator/advance.h:200
+void __advance_to(_Iter& __iter, _Sent& __to) {
+#if _LIBCPP_STD_VER > 17
+  ranges::advance(__iter, __to);
----------------
does it need to check `_LIBCPP_HAS_NO_INCOMPLETE_RANGES` too? 


================
Comment at: libcxx/include/__iterator/advance.h:201
+#if _LIBCPP_STD_VER > 17
+  ranges::advance(__iter, __to);
+#else
----------------
What if this line is called on C++20 mode with the classic algorithm/classic iterator?

C++20 `sentinel_for` requires the sentinel to be `semiregular`. But C++ 17's iterator are not required to be default constructible.

what happens if you call the classic algorithm with a classic iterator that is not default constructible?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124079



More information about the libcxx-commits mailing list