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

来自cppreference.com
< cpp‎ | chrono‎ | month
 
 
 
 
定义于头文件 <chrono>
constexpr bool operator==( const std::chrono::month& x,
                           const std::chrono::month& y ) noexcept;
(1) (C++20 起)
constexpr std::strong_ordering operator<=>( const std::chrono::month& x,
                                            const std::chrono::month& y ) noexcept;
(2) (C++20 起)

比较二个 std::chrono::month xy

<<=>>=!= 运算符分别从 operator<=>operator== 合成

返回值

1) unsigned(x) == unsigned(y)
2) unsigned(x) <=> unsigned(y)

示例

#include <iostream>
#include <chrono>
 
int main()
{
    constexpr std::chrono::month m1{6};
    constexpr std::chrono::month m2{8};
 
    std::cout << std::boolalpha
        << (m1 < m2) << ' ' << (m1 == m1) << ' ' << (m1 <= m2) << ' '
        << (m2 > m1) << ' ' << (m2 != m1) << ' ' << (m2 >= m1) << '\n';
}

输出:

true true true true true true