[libcxx-commits] [libcxx] [libc++][ranges][enumerate_view] Fix iterator converting constructor test (PR #212044)
Lucas Mellone via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jul 30 04:23:19 PDT 2026
================
@@ -64,6 +73,17 @@ constexpr void test() {
assert(index == 1);
assert(value == 84);
}
+ {
+ // underlying non-const to const not convertible
+ int buffer[3] = {1, 2, 3};
+ std::ranges::enumerate_view v(ConstIterIncompatibleView{buffer});
+ auto iter1 = v.begin();
+ auto iter2 = std::as_const(v).begin();
+
+ static_assert(!std::is_same_v<decltype(iter1), decltype(iter2)>);
----------------
lknknm wrote:
> Can we use the std::same_as concept and get away without including <type_traits>?
Yes and we can also remove the `<type_traits>` include.
> Please make sure you are testing the converting constructor and nothing else? Remove/Update the redundant test cases.
I'm still not quite sure if the other tests are redundant or complementary. I'm thinking even about moving the test I've added to another function because it doesn't have much to do with the other current ones given they receive different types of iterators through template arguments.
Maybe we can refactor the new test case to fit into that and remove the other ones as needed? There's another test case in `range.zip/iterator/ctor.other.pass.cpp` that might fit into our scenario.
Wdyt?
https://github.com/llvm/llvm-project/pull/212044
More information about the libcxx-commits
mailing list