std::chrono...eap_second)(3)
π std::chrono::operator==,<=>,(std::chrono::leap_second) β¨
okay bestie, so this whole page is the comparison operators for std::chrono::leap_second β the ones from the C++ standard library, std::chrono corner, and yeah the title up there is literally std::chrono::operator==,<=>,(std::chrono::leap_second). say it three times fast, i dare you π«Ά
πΈ NAME πΈ
std::chrono::operator==,<=>,(std::chrono::leap_second) β like, the full set: std::chrono::operator==,<=>,(std::chrono::leap_second). all the equality and ordering comparisons for leap seconds. iconic behavior honestly π
β¨ Synopsis β¨
first things first, it's defined in header <chrono> β don't forget to #include her π
here come all twelve overloads, no cap, all of them, and every single one is (since C++20):
(1)
constexpr bool operator==( const std::chrono::leap_second& x,
const std::chrono::leap_second& y ) noexcept;
(2)
constexpr std::strong_ordering operator<=>( const std::chrono::leap_second& x,
const std::chrono::leap_second& y ) noexcept;
(3)
template< class Duration >
constexpr bool operator==( const std::chrono::leap_second& x,
const std::chrono::sys_time<Duration>& y ) noexcept;
(4)
template< class Duration >
constexpr bool operator< ( const std::chrono::leap_second& x,
const std::chrono::sys_time<Duration>& y ) noexcept;
(5)
template< class Duration >
constexpr bool operator< ( const std::chrono::sys_time<Duration>& x,
const std::chrono::leap_second& y ) noexcept;
(6)
template< class Duration >
constexpr bool operator> ( const std::chrono::leap_second& x,
const std::chrono::sys_time<Duration>& y ) noexcept;
(7)
template< class Duration >
constexpr bool operator> ( const std::chrono::sys_time<Duration>& x,
const std::chrono::leap_second& y ) noexcept;
(8)
template< class Duration >
constexpr bool operator<=( const std::chrono::leap_second& x,
const std::chrono::sys_time<Duration>& y ) noexcept;
(9)
template< class Duration >
constexpr bool operator<=( const std::chrono::sys_time<Duration>& x,
const std::chrono::leap_second& y ) noexcept;
(10)
template< class Duration >
constexpr bool operator>=( const std::chrono::leap_second& x,
const std::chrono::sys_time<Duration>& y ) noexcept;
(11)
template< class Duration >
constexpr bool operator>=( const std::chrono::sys_time<Duration>& x,
const std::chrono::leap_second& y ) noexcept;
(12) β miss girl has a requires clause, she's fancy π
template< class Duration >
requires std::three_way_comparable_with<
std::chrono::sys_seconds,
std::chrono::sys_time<Duration>>
constexpr auto operator<=>( const std::chrono::leap_second& x,
const std::chrono::sys_time<Duration>& y ) noexcept;
so what do they actually do? they compare the date and time represented by the objects x and y. that's the whole vibe π¦
ngl there's a detail here you're gonna wanna know: the return type of (12) is deduced from x.date() <=> y, and hence it's the three-way comparison result type of std::chrono::seconds and Duration. lowkey genius, fr fr π
and hiiighkey important: the != operator is synthesized from operator==. you don't get a hand-written one, she's generated. periodt π
π Return value π
one bullet per overload, exactly what each one hands back to you, no guessing:
x.date() == y.date()x.date() <=> y.date()x.date() == yx.date() < yx < y.date()x.date() > yx > y.date()x.date() <= yx <= y.date()x.date() >= yx >= y.date()x.date() <=> y
π friendly reminder bestie: every one of these overloads is(since C++20)andnoexcept. if your compiler's being weird about them, check your standard version first before you spiral π
okay that's the whole page, you ate that π this lovely little number comes to you from http://cppreference.com, dated 2024.06.10, and the page itself is std::chrono...eap_second)(3) β go forth and compare your leap seconds with confidence, i'm obsessed π§β
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms