Skip to content

Commit

Permalink
Merge pull request opencv#3127 from GravityJack:size-math-ops
Browse files Browse the repository at this point in the history
  • Loading branch information
vpisarev committed Aug 22, 2014
2 parents b56933d + 17e8d51 commit 0eb1c7e
Showing 1 changed file with 35 additions and 6 deletions.
41 changes: 35 additions & 6 deletions modules/core/include/opencv2/core/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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);
}


Expand Down

0 comments on commit 0eb1c7e

Please sign in to comment.