Fix for ccls:Vec not building with MVS

This commit is contained in:
Martin Baliet 2019-03-18 22:59:25 +01:00
parent fd48f6928e
commit 8fd48f4549

View File

@ -143,7 +143,7 @@ public:
template <typename T> struct Vec { template <typename T> struct Vec {
std::unique_ptr<T[]> a; std::unique_ptr<T[]> a;
int s; int s = 0;
const T *begin() const { return a.get(); } const T *begin() const { return a.get(); }
T *begin() { return a.get(); } T *begin() { return a.get(); }
const T *end() const { return a.get() + s; } const T *end() const { return a.get() + s; }
@ -151,5 +151,16 @@ template <typename T> struct Vec {
int size() const { return s; } int size() const { return s; }
const T &operator[](size_t i) const { return a.get()[i]; } const T &operator[](size_t i) const { return a.get()[i]; }
T &operator[](size_t i) { return a.get()[i]; } T &operator[](size_t i) { return a.get()[i]; }
Vec &operator=(Vec &&rhs) {
a = std::move(rhs.a);
s = rhs.s;
return *this;
}
Vec(const Vec &lhs) : a(std::make_unique<T[]>(lhs.s)), s(lhs.s) {
std::copy(lhs.begin(), lhs.end(), begin());
s = lhs.s;
}
Vec(std::unique_ptr<T[]> &&a_, int size) : a(std::move(a_)), s(size) {}
Vec(){};
}; };
} // namespace ccls } // namespace ccls