From 6cf30e175111b3299a3cd03f229a79cdfb7553f3 Mon Sep 17 00:00:00 2001 From: Jan Haller Date: Wed, 21 Aug 2013 12:12:34 +0200 Subject: [PATCH] Added operator for division of two sf::Time objects --- include/SFML/System/Time.hpp | 12 ++++++++++++ src/SFML/System/Time.cpp | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/include/SFML/System/Time.hpp b/include/SFML/System/Time.hpp index 9d381486..4df57052 100644 --- a/include/SFML/System/Time.hpp +++ b/include/SFML/System/Time.hpp @@ -399,6 +399,18 @@ SFML_SYSTEM_API Time& operator /=(Time& left, float right); //////////////////////////////////////////////////////////// SFML_SYSTEM_API Time& operator /=(Time& left, Int64 right); +//////////////////////////////////////////////////////////// +/// \relates Time +/// \brief Overload of binary / operator to compute the ratio of two time values +/// +/// \param left Left operand (a time) +/// \param right Right operand (a time) +/// +/// \return \a left divided by \a right +/// +//////////////////////////////////////////////////////////// +SFML_SYSTEM_API float operator /(Time left, Time right); + //////////////////////////////////////////////////////////// /// \relates Time /// \brief Overload of binary % operator to compute remainder of a time value diff --git a/src/SFML/System/Time.cpp b/src/SFML/System/Time.cpp index 14455730..b41ae9d4 100644 --- a/src/SFML/System/Time.cpp +++ b/src/SFML/System/Time.cpp @@ -237,6 +237,13 @@ Time& operator /=(Time& left, Int64 right) } +//////////////////////////////////////////////////////////// +float operator /(Time left, Time right) +{ + return left.asSeconds() / right.asSeconds(); +} + + //////////////////////////////////////////////////////////// Time operator %(Time left, Time right) {