mirror of
https://github.com/SFML/SFML.git
synced 2024-12-03 08:41:04 +08:00
Merge pull request #430 from Foaly/timeOperators
Added modulo operators for sf::Time (#429)
This commit is contained in:
commit
a7f7c57a72
@ -399,6 +399,30 @@ SFML_SYSTEM_API Time& operator /=(Time& left, float right);
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
SFML_SYSTEM_API Time& operator /=(Time& left, Int64 right);
|
SFML_SYSTEM_API Time& operator /=(Time& left, Int64 right);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \relates Time
|
||||||
|
/// \brief Overload of binary % operator to compute remainder of a time value
|
||||||
|
///
|
||||||
|
/// \param left Left operand (a time)
|
||||||
|
/// \param right Right operand (a time)
|
||||||
|
///
|
||||||
|
/// \return \a left modulo \a right
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
SFML_SYSTEM_API Time operator %(Time left, Time right);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \relates Time
|
||||||
|
/// \brief Overload of binary %= operator to compute/assign remainder of a time value
|
||||||
|
///
|
||||||
|
/// \param left Left operand (a time)
|
||||||
|
/// \param right Right operand (a time)
|
||||||
|
///
|
||||||
|
/// \return \a left modulo \a right
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
SFML_SYSTEM_API Time& operator %=(Time& left, Time right);
|
||||||
|
|
||||||
} // namespace sf
|
} // namespace sf
|
||||||
|
|
||||||
|
|
||||||
|
@ -236,4 +236,18 @@ Time& operator /=(Time& left, Int64 right)
|
|||||||
return left = left / right;
|
return left = left / right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
Time operator %(Time left, Time right)
|
||||||
|
{
|
||||||
|
return microseconds(left.asMicroseconds() % right.asMicroseconds());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
Time& operator %=(Time& left, Time right)
|
||||||
|
{
|
||||||
|
return left = left % right;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace sf
|
} // namespace sf
|
||||||
|
Loading…
Reference in New Issue
Block a user