std::chrono...h_day_last)(3)
πΈ 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 π
- Overload (1) gives you exactly
x.year() == y.year() && x.month() == y.month()β iconic. - 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
- 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