[libcxx-commits] [libcxx] 8685915 - [libc++][ranges] Fix `iota_view`'s constructor's incorrect constraint
via libcxx-commits
libcxx-commits at lists.llvm.org
Fri May 12 11:22:30 PDT 2023
Author: Hui
Date: 2023-05-12T19:22:13+01:00
New Revision: 868591501c61bc1aa56da537bab85cc67439f16d
URL: https://github.com/llvm/llvm-project/commit/868591501c61bc1aa56da537bab85cc67439f16d
DIFF: https://github.com/llvm/llvm-project/commit/868591501c61bc1aa56da537bab85cc67439f16d.diff
LOG: [libc++][ranges] Fix `iota_view`'s constructor's incorrect constraint
One of the overload of the constructors should check Bound is not unreachable_sentinel_t, instead of the Start
Differential Revision: https://reviews.llvm.org/D150206
Added:
Modified:
libcxx/include/__ranges/iota_view.h
libcxx/test/std/ranges/range.factories/range.iota.view/ctor.first.last.pass.cpp
Removed:
################################################################################
diff --git a/libcxx/include/__ranges/iota_view.h b/libcxx/include/__ranges/iota_view.h
index 52e8e822f566d..ebfa0220070a5 100644
--- a/libcxx/include/__ranges/iota_view.h
+++ b/libcxx/include/__ranges/iota_view.h
@@ -336,7 +336,7 @@ namespace ranges {
_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
diff --git a/libcxx/test/std/ranges/range.factories/range.iota.view/ctor.first.last.pass.cpp b/libcxx/test/std/ranges/range.factories/range.iota.view/ctor.first.last.pass.cpp
index ee0e7fceffa61..67b7dc428a14f 100644
--- a/libcxx/test/std/ranges/range.factories/range.iota.view/ctor.first.last.pass.cpp
+++ b/libcxx/test/std/ranges/range.factories/range.iota.view/ctor.first.last.pass.cpp
@@ -76,6 +76,12 @@ constexpr bool test() {
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;
}
More information about the libcxx-commits
mailing list