[libcxx-commits] [libcxx] WIP [libc++][ranges] Add `convertible_to` test case for `enumerate_view` iterator ctor test (PR #212044)

Lucas Mellone via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jul 29 14:51:46 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)>);
+    static_assert(!std::constructible_from<decltype(iter1), decltype(iter2)>);
+    static_assert(!std::constructible_from<decltype(iter2), decltype(iter1)>);
+  }
----------------
lknknm wrote:

@frederick-vs-ja / @Zingam please check.
I ported this test case from `libcxx/test/std/ranges/range.zip/iterator/ctor.other.pass.cpp` and I think it fits the negative case which Jiang An was talking about. 

https://github.com/llvm/llvm-project/pull/212044


More information about the libcxx-commits mailing list