|
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | ||||
| Nonmember functions | ||||
operator==operator<=> | ||||
| Helper classes | ||||
Defined in header <chrono> | ||
constexprbool operator==(conststd::chrono::year_month_day& x, conststd::chrono::year_month_day& y)noexcept; | (1) | (since C++20) |
constexprstd::strong_ordering operator<=>(conststd::chrono::year_month_day& x, | (2) | (since C++20) |
Compares the twoyear_month_day valuesx andy. This is a lexicographical comparison: theyear() is compared first, thenmonth(), thenday().
The<,<=,>,>=, and!= operators aresynthesized fromoperator<=> andoperator== respectively.
If bothx andy represent valid dates (x.ok()&& y.ok()==true), the result of the lexicographical comparison is consistent with the calendar order.
#include <chrono> int main(){constexprauto ymd1{std::chrono::day(13)/7/1337};constexprauto ymd2{std::chrono::year(1337)/7/13}; static_assert(ymd1== ymd2); static_assert(ymd1<= ymd2); static_assert(ymd1>= ymd2); static_assert(ymd1<=> ymd2==0);}