Lines Matching full:arrayref
1 //===--- ArrayRef.h - Array Reference Wrapper -------------------*- C++ -*-===//
19 /// ArrayRef - Represent a constant reference to an array (0 or more elements
25 /// extends past that of the ArrayRef. For this reason, it is not in general
26 /// safe to store an ArrayRef.
31 class ArrayRef {
50 /// Construct an empty ArrayRef.
51 /*implicit*/ ArrayRef() : Data(nullptr), Length(0) {}
53 /// Construct an empty ArrayRef from None.
54 /*implicit*/ ArrayRef(NoneType) : Data(nullptr), Length(0) {}
56 /// Construct an ArrayRef from a single element.
57 /*implicit*/ ArrayRef(const T &OneElt)
60 /// Construct an ArrayRef from a pointer and length.
61 /*implicit*/ ArrayRef(const T *data, size_t length)
64 /// Construct an ArrayRef from a range.
65 ArrayRef(const T *begin, const T *end)
68 /// Construct an ArrayRef from a SmallVector. This is templated in order to
70 /// copy-construct an ArrayRef.
72 /*implicit*/ ArrayRef(const SmallVectorTemplateCommon<T, U> &Vec)
76 /// Construct an ArrayRef from a std::vector.
78 /*implicit*/ ArrayRef(const std::vector<T, A> &Vec)
81 /// Construct an ArrayRef from a C array.
83 /*implicit*/ LLVM_CONSTEXPR ArrayRef(const T (&Arr)[N])
86 /// Construct an ArrayRef from a std::initializer_list.
87 /*implicit*/ ArrayRef(const std::initializer_list<T> &Vec)
91 /// Construct an ArrayRef<const T*> from ArrayRef<T*>. This uses SFINAE to
94 ArrayRef(const ArrayRef<U *> &A,
129 // copy - Allocate copy in Allocator and return ArrayRef<T> to it.
130 template <typename Allocator> ArrayRef<T> copy(Allocator &A) {
133 return ArrayRef<T>(Buff, Length);
137 bool equals(ArrayRef RHS) const {
146 ArrayRef<T> slice(unsigned N) const {
148 return ArrayRef<T>(data()+N, size()-N);
153 ArrayRef<T> slice(unsigned N, unsigned M) const {
155 return ArrayRef<T>(data()+N, M);
159 ArrayRef<T> drop_back(unsigned N = 1) const {
202 class MutableArrayRef : public ArrayRef<T> {
209 /*implicit*/ MutableArrayRef() : ArrayRef<T>() {}
212 /*implicit*/ MutableArrayRef(NoneType) : ArrayRef<T>() {}
215 /*implicit*/ MutableArrayRef(T &OneElt) : ArrayRef<T>(OneElt) {}
219 : ArrayRef<T>(data, length) {}
222 MutableArrayRef(T *begin, T *end) : ArrayRef<T>(begin, end) {}
226 : ArrayRef<T>(Vec) {}
230 : ArrayRef<T>(Vec) {}
235 : ArrayRef<T>(Arr) {}
237 T *data() const { return const_cast<T*>(ArrayRef<T>::data()); }
279 /// @name ArrayRef Convenience constructors
282 /// Construct an ArrayRef from a single element.
284 ArrayRef<T> makeArrayRef(const T &OneElt) {
288 /// Construct an ArrayRef from a pointer and length.
290 ArrayRef<T> makeArrayRef(const T *data, size_t length) {
291 return ArrayRef<T>(data, length);
294 /// Construct an ArrayRef from a range.
296 ArrayRef<T> makeArrayRef(const T *begin, const T *end) {
297 return ArrayRef<T>(begin, end);
300 /// Construct an ArrayRef from a SmallVector.
302 ArrayRef<T> makeArrayRef(const SmallVectorImpl<T> &Vec) {
306 /// Construct an ArrayRef from a SmallVector.
308 ArrayRef<T> makeArrayRef(const SmallVector<T, N> &Vec) {
312 /// Construct an ArrayRef from a std::vector.
314 ArrayRef<T> makeArrayRef(const std::vector<T> &Vec) {
318 /// Construct an ArrayRef from a C array.
320 ArrayRef<T> makeArrayRef(const T (&Arr)[N]) {
321 return ArrayRef<T>(Arr);
325 /// @name ArrayRef Comparison Operators
329 inline bool operator==(ArrayRef<T> LHS, ArrayRef<T> RHS) {
334 inline bool operator!=(ArrayRef<T> LHS, ArrayRef<T> RHS) {
342 template <typename T> struct isPodLike<ArrayRef<T> > {