[libcxx-commits] [PATCH] D150206: [libc++][ranges] Fix `iota_view`'s constructor's incorrect constraint

Hui via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue May 9 09:47:20 PDT 2023


huixie90 created this revision.
huixie90 added reviewers: ldionne, philnik, var-const.
Herald added a project: All.
huixie90 requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

One of the overload of the constructors should check Bound is not unreachable_sentinel_t, instead of the Start


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150206

Files:
  libcxx/include/__ranges/iota_view.h
  libcxx/test/std/ranges/range.factories/range.iota.view/ctor.first.last.pass.cpp


Index: libcxx/test/std/ranges/range.factories/range.iota.view/ctor.first.last.pass.cpp
===================================================================
--- libcxx/test/std/ranges/range.factories/range.iota.view/ctor.first.last.pass.cpp
+++ libcxx/test/std/ranges/range.factories/range.iota.view/ctor.first.last.pass.cpp
@@ -76,6 +76,12 @@
     assert(std::ranges::next(io.begin(), 10) == io.end());
   }
 
+  {
+    std::ranges::iota_view<int, std::unreachable_sentinel_t> iv1;
+    // There should be only one overload available and {} resolves to unreachable_sentinel_t
+    [[maybe_unused]] std::ranges::iota_view<int, std::unreachable_sentinel_t> iv2(iv1.begin(), {});
+  }
+
   return true;
 }
 
Index: libcxx/include/__ranges/iota_view.h
===================================================================
--- libcxx/include/__ranges/iota_view.h
+++ libcxx/include/__ranges/iota_view.h
@@ -336,7 +336,7 @@
 
     _LIBCPP_HIDE_FROM_ABI
     constexpr _LIBCPP_EXPLICIT_SINCE_CXX23 iota_view(__iterator __first, __sentinel __last)
-      requires(!same_as<_Start, _BoundSentinel> && !same_as<_Start, unreachable_sentinel_t>)
+      requires(!same_as<_Start, _BoundSentinel> && !same_as<_BoundSentinel, unreachable_sentinel_t>)
     : iota_view(std::move(__first.__value_), std::move(__last.__bound_sentinel_)) {}
 
     _LIBCPP_HIDE_FROM_ABI


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150206.520733.patch
Type: text/x-patch
Size: 1348 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230509/04ce4a0c/attachment.bin>


More information about the libcxx-commits mailing list