Add memberwise remainter operators for Point

This commit is contained in:
Dmitry Marakasov 2015-07-03 22:00:59 +03:00
parent 0215d2526e
commit 1001bf8fa2
2 changed files with 31 additions and 0 deletions

View File

@ -78,6 +78,10 @@ Point Point::operator/(int value) const {
return Point(x / value, y / value); return Point(x / value, y / value);
} }
Point Point::operator%(int value) const {
return Point(x % value, y % value);
}
Point Point::operator*(int value) const { Point Point::operator*(int value) const {
return Point(x * value, y * value); return Point(x * value, y * value);
} }
@ -103,6 +107,13 @@ Point& Point::operator/=(int value) {
return *this; return *this;
} }
Point& Point::operator%=(int value) {
x %= value;
y %= value;
return *this;
}
Point& Point::operator*=(int value) { Point& Point::operator*=(int value) {
x *= value; x *= value;
y *= value; y *= value;

View File

@ -186,6 +186,16 @@ public:
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Point operator/(int value) const; Point operator/(int value) const;
////////////////////////////////////////////////////////////
/// \brief Get point's memberwise remainder from integer division
///
/// \param[in] value Divisor
///
/// \returns New Point representing memberwise remainder from point divided by an integer
///
////////////////////////////////////////////////////////////
Point operator%(int value) const;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Get point's memberwise multiplication by an integer /// \brief Get point's memberwise multiplication by an integer
/// ///
@ -226,6 +236,16 @@ public:
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Point& operator/=(int value); Point& operator/=(int value);
////////////////////////////////////////////////////////////
/// \brief Memberwise remainder from integer division
///
/// \param[in] value Divisor
///
/// \returns Reference to self
///
////////////////////////////////////////////////////////////
Point& operator%=(int value);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Memberwise multiply by an integer /// \brief Memberwise multiply by an integer
/// ///