year_operator_cmp

year_operator_cmp (year 비교 연산)

std::chrono::year에 대한 비교 연산자예요. 두 year==<=>로 비교해요.

출처: cppreference

본문

std::chrono::year의 비교 연산자는 <chrono> 헤더에 정의되어 있어요. C++20부터 사용 가능해요.

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

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

std::chrono::year xy를 비교해요.

반환값 (Return value)

  • operator==int(x) == int(y)
  • operator<=>int(x) <=> int(y)

예제 (Example)

#include <chrono>
#include <iostream>

int main()
{
    using namespace std::chrono;
    year y1{2020}, y2{2020};
    std::cout << (y1 == y2) << '\n'; // 1
}

더 알아보기 (Learn more)

cppreference