diff options
author | Hui <hui.xie0621@gmail.com> | 2023-05-09 17:41:15 +0100 |
---|---|---|
committer | Hui <hui.xie0621@gmail.com> | 2023-05-12 19:22:13 +0100 |
commit | 868591501c61bc1aa56da537bab85cc67439f16d (patch) | |
tree | ab0cd93d5b6878c5c12be0d37f2d63c8780bf35e /libcxx | |
parent | e351b9b66da088e5905ad3238ccf11e777943ead (diff) | |
download | llvm-868591501c61bc1aa56da537bab85cc67439f16d.tar.gz |
[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
Diffstat (limited to 'libcxx')
-rw-r--r-- | libcxx/include/__ranges/iota_view.h | 2 | ||||
-rw-r--r-- | libcxx/test/std/ranges/range.factories/range.iota.view/ctor.first.last.pass.cpp | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/libcxx/include/__ranges/iota_view.h b/libcxx/include/__ranges/iota_view.h index 52e8e822f566..ebfa0220070a 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 ee0e7fceffa6..67b7dc428a14 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; } |