[llvm] [ArrayRef] Add constructor from iterator_range<U*> (NFC). (PR #137796)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 30 02:20:45 PDT 2025


================
@@ -149,6 +149,13 @@ namespace llvm {
                  * = nullptr)
         : Data(Vec.data()), Length(Vec.size()) {}
 
+    /// Construct an ArrayRef<T> from iterator_range<U*>. This uses SFINAE
+    /// to ensure that this is only used for iterator ranges over plain pointer
+    /// iterators.
+    template <typename U, typename = std::enable_if_t<std::is_same_v<U *, T *>>>
----------------
artagnon wrote:

Not 100% sure if is_convertible is the best thing to do here: maybe `is_same_v<U, remove_const_t<T>>` is better?

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


More information about the llvm-commits mailing list