mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-24 22:07:39 +00:00
Fix copy and move assigments of Array
This commit is contained in:
parent
803c5377a6
commit
59ba350f34
@ -67,17 +67,30 @@ public:
|
||||
T* _node;
|
||||
};
|
||||
|
||||
T& operator = (const T& a) {
|
||||
Array &operator=(const Array& a) {
|
||||
delete [] _data;
|
||||
_data = nullptr;
|
||||
_size = a._size;
|
||||
_capacity = a._capacity;
|
||||
if (_capacity) {
|
||||
_data = new T[_capacity];
|
||||
for(int i = 0; i < _size; ++i)
|
||||
_data[i] = utils::move(a[i]);
|
||||
_data[i] = a[i];
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
Array &operator=(Array&& a) {
|
||||
delete [] _data;
|
||||
_size = a._size;
|
||||
_capacity = a._capacity;
|
||||
_data = a._data;
|
||||
a._size = 0;
|
||||
a._capacity = 0;
|
||||
a._data = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
iterator begin() const { return iterator(_data); }
|
||||
|
||||
iterator end() const { return iterator(_data + _size); }
|
||||
|
Loading…
x
Reference in New Issue
Block a user