提交 470369a8 编写于 作者: B Behdad Esfahbod

[array] Add arithmetic operators

上级 6cd60c2f
......@@ -60,12 +60,9 @@ struct hb_array_t
}
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 @@ struct hb_array_t
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.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册