提交 0eb1c7ed 编写于 作者: V Vadim Pisarevsky

Merge pull request #3127 from GravityJack:size-math-ops

......@@ -1311,23 +1311,36 @@ _Tp Size_<_Tp>::area() const
return width * height;
}
template<typename _Tp> static inline
Size_<_Tp>& operator *= (Size_<_Tp>& a, _Tp b)
{
a.width *= b;
a.height *= b;
return a;
}
template<typename _Tp> static inline
Size_<_Tp> operator * (const Size_<_Tp>& a, _Tp b)
{
return Size_<_Tp>(a.width * b, a.height * b);
Size_<_Tp> tmp(a);
tmp *= b;
return tmp;
}
template<typename _Tp> static inline
Size_<_Tp> operator + (const Size_<_Tp>& a, const Size_<_Tp>& b)
Size_<_Tp>& operator /= (Size_<_Tp>& a, _Tp b)
{
return Size_<_Tp>(a.width + b.width, a.height + b.height);
a.width /= b;
a.height /= b;
return a;
}
template<typename _Tp> static inline
Size_<_Tp> operator - (const Size_<_Tp>& a, const Size_<_Tp>& b)
Size_<_Tp> operator / (const Size_<_Tp>& a, _Tp b)
{
return Size_<_Tp>(a.width - b.width, a.height - b.height);
Size_<_Tp> tmp(a);
tmp /= b;
return tmp;
}
template<typename _Tp> static inline
......@@ -1338,6 +1351,14 @@ Size_<_Tp>& operator += (Size_<_Tp>& a, const Size_<_Tp>& b)
return a;
}
template<typename _Tp> static inline
Size_<_Tp> operator + (const Size_<_Tp>& a, const Size_<_Tp>& b)
{
Size_<_Tp> tmp(a);
tmp += b;
return tmp;
}
template<typename _Tp> static inline
Size_<_Tp>& operator -= (Size_<_Tp>& a, const Size_<_Tp>& b)
{
......@@ -1346,6 +1367,14 @@ Size_<_Tp>& operator -= (Size_<_Tp>& a, const Size_<_Tp>& b)
return a;
}
template<typename _Tp> static inline
Size_<_Tp> operator - (const Size_<_Tp>& a, const Size_<_Tp>& b)
{
Size_<_Tp> tmp(a);
tmp -= b;
return tmp;
}
template<typename _Tp> static inline
bool operator == (const Size_<_Tp>& a, const Size_<_Tp>& b)
{
......@@ -1355,7 +1384,7 @@ bool operator == (const Size_<_Tp>& a, const Size_<_Tp>& b)
template<typename _Tp> static inline
bool operator != (const Size_<_Tp>& a, const Size_<_Tp>& b)
{
return a.width != b.width || a.height != b.height;
return !(a == b);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册