[llvm] [ArrayRef] Add constructor from iterator_range<U*> (NFC). (PR #137796)
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 29 10:17:05 PDT 2025
================
@@ -149,6 +149,20 @@ 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 of random access
+ /// iterators that can be converted.
+ template <typename U,
+ typename = std::enable_if<
----------------
dwblaikie wrote:
Probably still worth using `std::enable_if_t` here, but without explicitly specifying a type parameter (the default is void, so that's fine) - if you are using `std::enable_if` then I think you have to add the `::type` at the end (that's where the SFINAE is - `std::enable_if<false>` has no nested `type` member, but `std::enable_if<true>` does)
Speaking of which - perhaps you could use some static_asserts to check that this SFINAE is rejecting the relevant cases in this condition?
Also - perhaps you could explain more how this condition works? It's not clear to me it does what we want/can detect contiguous sequences.
https://github.com/llvm/llvm-project/pull/137796
More information about the llvm-commits
mailing list