[libcxx-commits] [PATCH] D133220: [libc++][ranges] fix errors on passing input iterator to `std::views::take`
Hui via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Sep 23 04:21:09 PDT 2022
huixie90 updated this revision to Diff 462439.
huixie90 marked 6 inline comments as done.
huixie90 added a comment.
addressed comments
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D133220/new/
https://reviews.llvm.org/D133220
Files:
libcxx/include/__ranges/take_view.h
libcxx/test/std/ranges/range.adaptors/range.take/adaptor.pass.cpp
Index: libcxx/test/std/ranges/range.adaptors/range.take/adaptor.pass.cpp
===================================================================
--- libcxx/test/std/ranges/range.adaptors/range.take/adaptor.pass.cpp
+++ libcxx/test/std/ranges/range.adaptors/range.take/adaptor.pass.cpp
@@ -194,6 +194,19 @@
[[maybe_unused]] auto partial = std::views::take(X{});
}
+ // Test when `subrange<Iter>` is not well formed
+ {
+ int input[] = {1, 2, 3};
+ using Iter = cpp20_input_iterator<int*>;
+ using Sent = sentinel_wrapper<Iter>;
+ std::ranges::subrange r{Iter{input}, Sent{Iter{input + 3}}};
+ auto tv = std::views::take(std::move(r), 1);
+ auto it = tv.begin();
+ assert(*it == 1);
+ ++it;
+ assert(it == tv.end());
+ }
+
return true;
}
Index: libcxx/include/__ranges/take_view.h
===================================================================
--- libcxx/include/__ranges/take_view.h
+++ libcxx/include/__ranges/take_view.h
@@ -226,6 +226,7 @@
};
template <class _Iter, class _Sent, subrange_kind _Kind>
+ requires requires{typename subrange<_Iter>;}
struct __passthrough_type<subrange<_Iter, _Sent, _Kind>> {
using type = subrange<_Iter>;
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133220.462439.patch
Type: text/x-patch
Size: 1217 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220923/4cd08ce0/attachment.bin>
More information about the libcxx-commits
mailing list