year_month_operator_cmp
year_month_operator_cmp (year_month 비교 연산)
std::chrono::year_month에 대한 비교 연산자예요. 두 year_month를 ==와 <=>로 비교해요.
출처: cppreference
본문
std::chrono::year_month의 비교 연산자는 <chrono> 헤더에 정의되어 있어요. C++20부터 사용 가능해요.
constexpr bool operator==( const std::chrono::year_month& x,
const std::chrono::year_month& y ) noexcept;
constexpr std::strong_ordering operator<=>( const std::chrono::year_month& x,
const std::chrono::year_month& y ) noexcept;
두 std::chrono::year_month x와 y를 year()와 month()를 기준으로 비교해요.
예제 (Example)
#include <chrono>
#include <iostream>
int main()
{
using namespace std::chrono;
year_month ym1 = 2020y / July;
year_month ym2 = 2020y / July;
std::cout << (ym1 == ym2) << '\n'; // 1
}