mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:27:44 +00:00
AK: Reimplement comparisons on AK::Time using operator<=>
This allows us to make all comparision operators on the class constexpr without pulling in a bunch of boilerplate. We don't use the `<compare>` header because it doesn't compile in the main serenity cross-build due to the include paths to LibC being incompatible with how libc++ expects them to be for clang builds.
This commit is contained in:
parent
83ad5bfba0
commit
a8fcd39b88
3 changed files with 29 additions and 25 deletions
20
AK/Time.cpp
20
AK/Time.cpp
|
@ -256,26 +256,6 @@ Time& Time::operator-=(Time const& other)
|
|||
return *this;
|
||||
}
|
||||
|
||||
bool Time::operator<(Time const& other) const
|
||||
{
|
||||
return m_seconds < other.m_seconds || (m_seconds == other.m_seconds && m_nanoseconds < other.m_nanoseconds);
|
||||
}
|
||||
|
||||
bool Time::operator<=(Time const& other) const
|
||||
{
|
||||
return m_seconds < other.m_seconds || (m_seconds == other.m_seconds && m_nanoseconds <= other.m_nanoseconds);
|
||||
}
|
||||
|
||||
bool Time::operator>(Time const& other) const
|
||||
{
|
||||
return m_seconds > other.m_seconds || (m_seconds == other.m_seconds && m_nanoseconds > other.m_nanoseconds);
|
||||
}
|
||||
|
||||
bool Time::operator>=(Time const& other) const
|
||||
{
|
||||
return m_seconds > other.m_seconds || (m_seconds == other.m_seconds && m_nanoseconds >= other.m_nanoseconds);
|
||||
}
|
||||
|
||||
Time Time::from_half_sanitized(i64 seconds, i32 extra_seconds, u32 nanoseconds)
|
||||
{
|
||||
VERIFY(nanoseconds < 1'000'000'000);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue