[libcxx-commits] [libcxx] [libc++][NFC] Add additional tests for begin/end of std::ranges::take_view (PR #79085)
Will Hawkins via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Apr 8 05:24:55 PDT 2024
================
@@ -69,13 +81,51 @@ constexpr bool test() {
ASSERT_SAME_TYPE(decltype(tv.begin()), std::counted_iterator<int*>);
}
- // simple-view<V> && sized_range<V> && !size_range<!V>
+ // simple-view<V> && sized_range<V> && !sized_range<const V>
{
+ static_assert(simple_view<NonCommonSimpleView>);
+ static_assert(std::ranges::sized_range<NonCommonSimpleView>);
+ static_assert(!std::ranges::sized_range<const NonCommonSimpleView>);
+
std::ranges::take_view<NonCommonSimpleView> tv{};
ASSERT_SAME_TYPE(decltype(tv.begin()), std::counted_iterator<int*>);
ASSERT_SAME_TYPE(decltype(std::as_const(tv).begin()), std::counted_iterator<int*>);
}
+ // non simple-view<V> && !sized_range<V>
+ {
+ static_assert(!simple_view<NonSimpleNonSizedView>);
+ static_assert(!std::ranges::sized_range<NonSimpleNonSizedView>);
+
+ std::ranges::take_view<NonSimpleNonSizedView> tv{NonSimpleNonSizedView{buffer, buffer + 2}, 4};
+ // The count for the counted iterator is the count of the take_view (i.e., 4)
+ assert(tv.begin() ==
+ std::counted_iterator<common_input_iterator<const int*>>(common_input_iterator<const int*>(buffer), 4));
----------------
hawkinsw wrote:
Done!
https://github.com/llvm/llvm-project/pull/79085
More information about the libcxx-commits
mailing list