#include "llvm/ADT/None.h"
#include "llvm/ADT/SmallVector.h"
-#include "llvm/Support/Allocator.h"
#include <vector>
namespace llvm {
return Data[Length-1];
}
- // copy - Allocate copy in BumpPtrAllocator and return ArrayRef<T> to it.
- ArrayRef<T> copy(BumpPtrAllocator &Allocator) {
- T *Buff = Allocator.Allocate<T>(Length);
+ // copy - Allocate copy in Allocator and return ArrayRef<T> to it.
+ template <typename Allocator> ArrayRef<T> copy(Allocator &A) {
+ T *Buff = A.template Allocate<T>(Length);
std::copy(begin(), end(), Buff);
return ArrayRef<T>(Buff, Length);
}
bool equals(ArrayRef RHS) const {
if (Length != RHS.Length)
return false;
- for (size_type i = 0; i != Length; i++)
- if (Data[i] != RHS.Data[i])
- return false;
- return true;
+ return std::equal(begin(), end(), RHS.begin());
}
/// slice(n) - Chop off the first N elements of the array.
/// Construct an MutableArrayRef from a C array.
template <size_t N>
- /*implicit*/ MutableArrayRef(T (&Arr)[N])
+ /*implicit*/ LLVM_CONSTEXPR MutableArrayRef(T (&Arr)[N])
: ArrayRef<T>(Arr) {}
T *data() const { return const_cast<T*>(ArrayRef<T>::data()); }
#ifndef LLVM_ADT_STRINGREF_H
#define LLVM_ADT_STRINGREF_H
-#include "llvm/Support/Allocator.h"
#include <algorithm>
#include <cassert>
#include <cstring>
return Data[Length-1];
}
- // copy - Allocate copy in BumpPtrAllocator and return StringRef to it.
- StringRef copy(BumpPtrAllocator &Allocator) {
- char *S = Allocator.Allocate<char>(Length);
+ // copy - Allocate copy in Allocator and return StringRef to it.
+ template <typename Allocator> StringRef copy(Allocator &A) {
+ char *S = A.template Allocate<char>(Length);
std::copy(begin(), end(), S);
return StringRef(S, Length);
}