std::chrono...h_day_last)(3)

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

🌸 NAME 🌸

okay bestie, you're in the C++ Standard Libary man pages, section 3, and this page is for std::chrono::operator==,(std::chrono::year_month_day_last) β€” comma and all, that's literally the name:

std::chrono::operator==,(std::chrono::year_month_day_last) - std::chrono::operator==,(std::chrono::year_month_day_last)

(also the header-ish title goes std::chrono...h_day_last)(3), iykyk πŸ’…)


✨ Synopsis ✨

Defined in header <chrono>:

constexpr bool operator==( const std::chrono::year_month_day_last& x,
                           const std::chrono::year_month_day_last& y ) noexcept;

(1) (since C++20)

constexpr std::strong_ordering
    operator<=>( const std::chrono::year_month_day_last& x,
                 const std::chrono::year_month_day_last& y ) noexcept;

(2) (since C++20)

Here's the tea: this compares the two year_month_day_last values x and y. It's a lexicographical comparison β€” year() gets compared first, then month(). slay.

And the <, <=, >, >=, and != operators are synthesized from operator<=> and operator== respectively. no cap, the compiler handles that for you ✨


πŸ’… Return value πŸ’…

  1. Overload (1) gives you exactly x.year() == y.year() && x.month() == y.month() β€” iconic.
  2. Overload (2) gives you exactly x.year() <=> y.year() != 0 ? x.year() <=> y.year() : x.month() <=> y.month() β€” yes bestie, that's the whole conditional, periodt.

🧠 Notes 🧠

If both x and y represent valid dates (x.ok() && y.ok() == true), the result of the lexicographical comparison is consistent with the calendar order. that's the lil caveat, bestie 🫢


πŸŽ€ Example πŸŽ€

// Run this code β€” literally, go off:

#include <cassert>
#include <chrono>
#include <iostream>

int main()
{
    auto ymdl1{11/std::chrono::last/2020};
    auto mdl{std::chrono::last/std::chrono::November};
    auto ymdl2{mdl/2020};
    assert(ymdl1 == ymdl2);

    ymdl1 -= std::chrono::months{2};
    ymdl2 -= std::chrono::months{1};
    assert(ymdl1 < ymdl2);
}

mwah πŸ’‹ β€” this cutie came from http://cppreference.com, dated 2024.06.10, and it's the std::chrono...h_day_last)(3) page. periodt.

πŸ“¦ where this page comes from