[libcxx-commits] [libcxx] [libc++][ranges][enumerate_view] Update `size.pass.cpp` (PR #233777)
via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Oct 20 03:33:02 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Lucas Mellone (lknknm)
<details>
<summary>Changes</summary>
Completes the [range.enumerate.sentinel] `size` test by addressing the review comment https://github.com/llvm/llvm-project/pull/73617#discussion_r1416645016 from the original implementation.
---
Full diff: https://github.com/llvm/llvm-project/pull/233777.diff
1 Files Affected:
- (modified) libcxx/test/std/ranges/range.adaptors/range.enumerate/size.pass.cpp (+13)
``````````diff
diff --git a/libcxx/test/std/ranges/range.adaptors/range.enumerate/size.pass.cpp b/libcxx/test/std/ranges/range.adaptors/range.enumerate/size.pass.cpp
index 3e641d97ebecb3..84a2c6331df40f 100644
--- a/libcxx/test/std/ranges/range.adaptors/range.enumerate/size.pass.cpp
+++ b/libcxx/test/std/ranges/range.adaptors/range.enumerate/size.pass.cpp
@@ -38,6 +38,19 @@ static_assert(!std::ranges::sized_range<const NonSizedRangeView>);
static_assert(!HasMemberSize<std::ranges::enumerate_view<NonSizedRangeView>>);
static_assert(!HasMemberSize<const std::ranges::enumerate_view<NonSizedRangeView>>);
+struct NonConstSizedView : std::ranges::view_base {
+ using iterator = forward_iterator<int*>;
+ iterator begin() const;
+ iterator end() const;
+ std::size_t size();
+};
+
+// Test the pathological type where it is sized if it's const but not sized if it's const.
+static_assert(std::ranges::sized_range<NonConstSizedView>);
+static_assert(!std::ranges::sized_range<const NonConstSizedView>);
+static_assert(HasMemberSize<std::ranges::enumerate_view<NonConstSizedView>>);
+static_assert(!HasMemberSize<const std::ranges::enumerate_view<NonConstSizedView>>);
+
constexpr bool test() {
int buffer[] = {1, 2, 3};
``````````
</details>
https://github.com/llvm/llvm-project/pull/233777
More information about the libcxx-commits
mailing list