[array] Add operator +=

This commit is contained in:
Behdad Esfahbod 2018-12-16 23:45:07 -05:00
parent 7c0e3e9b2b
commit f85f6e815f
1 changed files with 9 additions and 9 deletions

View File

@ -57,6 +57,15 @@ struct hb_array_t
Type * operator & (void) const { return arrayZ; }
hb_array_t<Type> & operator += (unsigned int count)
{
if (unlikely (count > len))
count = len;
len -= count;
arrayZ += count;
return *this;
}
unsigned int get_size (void) const { return len * item_size; }
hb_array_t<Type> sub_array (unsigned int start_offset = 0, unsigned int *seg_count = nullptr /* IN/OUT */) const
@ -241,15 +250,6 @@ struct Supplier : hb_array_t<const Type>
this->len = v.len;
}
Supplier<Type> & operator += (unsigned int count)
{
if (unlikely (count > this->len))
count = this->len;
this->len -= count;
this->arrayZ += count;
return *this;
}
private:
Supplier (const Supplier<Type> &); /* Disallow copy */
Supplier<Type>& operator= (const Supplier<Type> &); /* Disallow copy */