std::chrono::operator==,<=>(std::chrono::year)
From cppreference.com
constexpr bool operator==( const std::chrono::year& x, const std::chrono::year& y ) noexcept; |
(1) | (since C++20) |
constexpr std::strong_ordering operator<=>( const std::chrono::year& x, const std::chrono::year& y ) noexcept; |
(2) | (since C++20) |
Compare the two std::chrono::year x
and y
.
Return value
1) int(x) == int(y)
2) int(x) <=> int(y)
Example
Run this code
#include <iostream> #include <chrono> int main() { std::chrono::year y1{2020}; std::chrono::year y2{2021}; if (y1 == y2) { std::cout << "y1 and y2 are equal" << "\n"; } else { std::cout << "y1 and y2 are not equal" << "\n"; } }
Output:
y1 and y2 are not equal