From 1001bf8fa211d539e4f3f4730aac843d34e3bc7e Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Fri, 3 Jul 2015 22:00:59 +0300 Subject: [PATCH] Add memberwise remainter operators for Point --- SDL2pp/Point.cc | 11 +++++++++++ SDL2pp/Point.hh | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/SDL2pp/Point.cc b/SDL2pp/Point.cc index c41cf7e..5ed4146 100644 --- a/SDL2pp/Point.cc +++ b/SDL2pp/Point.cc @@ -78,6 +78,10 @@ Point Point::operator/(int value) const { return Point(x / value, y / value); } +Point Point::operator%(int value) const { + return Point(x % value, y % value); +} + Point Point::operator*(int value) const { return Point(x * value, y * value); } @@ -103,6 +107,13 @@ Point& Point::operator/=(int value) { return *this; } +Point& Point::operator%=(int value) { + x %= value; + y %= value; + + return *this; +} + Point& Point::operator*=(int value) { x *= value; y *= value; diff --git a/SDL2pp/Point.hh b/SDL2pp/Point.hh index 5db0cc3..bae5ba6 100644 --- a/SDL2pp/Point.hh +++ b/SDL2pp/Point.hh @@ -186,6 +186,16 @@ public: //////////////////////////////////////////////////////////// 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 /// @@ -226,6 +236,16 @@ public: //////////////////////////////////////////////////////////// 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 ///