Add conversion constructor to convert ArrayRef<T*> to ArrayRef<const T*>. Reviewed with Chandler and David Blaikie.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216709 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Craig Topper 2014-08-29 06:01:43 +00:00
parent 3cd73a5ded
commit 95f7e2d2fd

View File

@ -104,6 +104,14 @@ namespace llvm {
Length(Vec.size()) {}
#endif
/// Construct an ArrayRef<const T*> from ArrayRef<T*>. This uses SFINAE to
/// ensure that only ArrayRefs of pointers can be converted.
template <typename U>
ArrayRef(const ArrayRef<U *> &A,
typename std::enable_if<
std::is_convertible<U *const *, T const *>::value>::type* = 0)
: Data(A.data()), Length(A.size()) {}
/// @}
/// @name Simple Operations
/// @{