std::chrono...eap_second)(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’… 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:

  1. x.date() == y.date()
  2. x.date() <=> y.date()
  3. x.date() == y
  4. x.date() < y
  5. x < y.date()
  6. x.date() > y
  7. x > y.date()
  8. x.date() <= y
  9. x <= y.date()
  10. x.date() >= y
  11. x >= y.date()
  12. x.date() <=> y
πŸ‘‘ friendly reminder bestie: every one of these overloads is (since C++20) and noexcept. 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