[libcxx-commits] [libcxx] [libc++][ranges][enumerate_view] Fix sentinel converting constructor test (PR #217365)

Hristo Hristov via libcxx-commits libcxx-commits at lists.llvm.org
Wed Aug 19 09:01:21 PDT 2026


================
@@ -28,6 +28,67 @@
 #include "test_iterators.h"
 
 #include "../types.h"
+#include "../../range_adaptor_types.h"
+
+template <class T>
+struct convertible_sentinel_wrapper {
+  explicit convertible_sentinel_wrapper() = default;
+  constexpr convertible_sentinel_wrapper(const T& it) : it_(it) {}
+
+  template <class U>
+    requires std::convertible_to<const U&, T>
+  constexpr convertible_sentinel_wrapper(const convertible_sentinel_wrapper<U>& other) : it_(other.it_) {}
+
+  constexpr friend bool operator==(convertible_sentinel_wrapper const& self, const T& other) {
+    return self.it_ == other;
+  }
+  T it_;
+};
+
+struct NonSimpleNonCommonConvertibleView : IntBufferView {
+  using IntBufferView::IntBufferView;
+
+  constexpr int* begin() { return buffer_; }
+  constexpr const int* begin() const { return buffer_; }
+  constexpr convertible_sentinel_wrapper<int*> end() { return convertible_sentinel_wrapper<int*>(buffer_ + size_); }
+  constexpr convertible_sentinel_wrapper<const int*> end() const {
+    return convertible_sentinel_wrapper<const int*>(buffer_ + size_);
+  }
+};
+
+// convertible_to<sentinel<false>, sentinel<Const>>
+static_assert(std::convertible_to< //
----------------
Zingam wrote:

```suggestion
static_assert(std::convertible_to<
```
Can we live without this forced formatting?

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


More information about the libcxx-commits mailing list