[array] Add arithmetic operators
diff --git a/src/hb-array.hh b/src/hb-array.hh index ae8d2d7..959f103 100644 --- a/src/hb-array.hh +++ b/src/hb-array.hh
@@ -60,12 +60,9 @@ } explicit_operator bool (void) const { return len; } - - template <typename T> operator T * (void) const { return arrayZ; } - Type * operator & (void) const { return arrayZ; } - Type & operator * (void) { return (this->operator [])[0]; } + template <typename T> operator T * (void) const { return arrayZ; } hb_array_t<Type> & operator += (unsigned int count) { @@ -75,6 +72,23 @@ arrayZ += count; return *this; } + hb_array_t<Type> & operator -= (unsigned int count) + { + if (unlikely (count > len)) + count = len; + len -= count; + return *this; + } + hb_array_t<Type> & operator ++ (void) { *this += 1; } + hb_array_t<Type> & operator -- (void) { *this -= 1; } + hb_array_t<Type> operator + (unsigned int count) + { hb_array_t<Type> copy (*this); *this += count; return copy; } + hb_array_t<Type> operator - (unsigned int count) + { hb_array_t<Type> copy (*this); *this -= count; return copy; } + hb_array_t<Type> operator ++ (int) + { hb_array_t<Type> copy (*this); ++*this; return copy; } + hb_array_t<Type> operator -- (int) + { hb_array_t<Type> copy (*this); --*this; return copy; } /* * Compare, Sort, and Search.