Namespaces
Variants

std::chrono:: operator==,<=> (std::chrono::year_month_day_last)

From cppreference.net
헤더 파일에 정의됨 <chrono>
constexpr bool operator == ( const std:: chrono :: year_month_day_last & x,
const std:: chrono :: year_month_day_last & y ) noexcept ;
(1) (C++20부터)
(2) (C++20부터)

두 개의 year_month_day_last x y 를 비교합니다. 이는 사전식 비교입니다: year() 가 먼저 비교되고, 그 다음 month() 가 비교됩니다.

< , <= , > , >= , 그리고 != 연산자들은 각각 합성됩니다 operator <=> operator == 로부터.

반환값

1) x. year ( ) == y. year ( ) && x. month ( ) == y. month ( )
2) x. year ( ) <=> y. year ( ) ! = 0 ? x. year ( ) <=> y. year ( ) : x. month ( ) <=> y. month ( )

참고 사항

만약 x y 가 모두 유효한 날짜를 나타낸다면 ( x. ok ( ) && y. ok ( ) == true ), 사전식 비교 결과는 달력 순서와 일치합니다.

예제

#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);
}